mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-10 15:48:49 +00:00
AbstractHafasProvider: Extract AbstractHafasMobileProvider and AbstractHafasLegacyProvider for the two Hafas APIs.
This commit is contained in:
parent
7dd43f90c5
commit
a0bec90f9a
40 changed files with 3891 additions and 4136 deletions
3044
enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java
Normal file
3044
enabler/src/de/schildbach/pte/AbstractHafasLegacyProvider.java
Normal file
File diff suppressed because it is too large
Load diff
751
enabler/src/de/schildbach/pte/AbstractHafasMobileProvider.java
Normal file
751
enabler/src/de/schildbach/pte/AbstractHafasMobileProvider.java
Normal file
|
@ -0,0 +1,751 @@
|
|||
/*
|
||||
* Copyright 2010-2017 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 static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import de.schildbach.pte.dto.Departure;
|
||||
import de.schildbach.pte.dto.Fare;
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Position;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.ResultHeader;
|
||||
import de.schildbach.pte.dto.StationDepartures;
|
||||
import de.schildbach.pte.dto.Stop;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
import de.schildbach.pte.dto.SuggestedLocation;
|
||||
import de.schildbach.pte.dto.Trip;
|
||||
import de.schildbach.pte.exception.ParserException;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public abstract class AbstractHafasMobileProvider extends AbstractHafasProvider {
|
||||
public HttpUrl mgateEndpoint;
|
||||
@Nullable
|
||||
public String apiVersion;
|
||||
@Nullable
|
||||
public String apiAuthorization;
|
||||
@Nullable
|
||||
public String apiClient;
|
||||
|
||||
public AbstractHafasMobileProvider(final NetworkId network, final HttpUrl apiBase, final Product[] productsMap) {
|
||||
super(network, productsMap);
|
||||
this.mgateEndpoint = apiBase.newBuilder().addPathSegment("mgate.exe").build();
|
||||
}
|
||||
|
||||
protected AbstractHafasMobileProvider setApiVersion(final String apiVersion) {
|
||||
this.apiVersion = apiVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected AbstractHafasMobileProvider setApiAuthorization(final String apiAuthorization) {
|
||||
this.apiAuthorization = apiAuthorization;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected AbstractHafasMobileProvider setApiClient(final String apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
protected final NearbyLocationsResult jsonLocGeoPos(final EnumSet<LocationType> types, final int lat, final int lon)
|
||||
throws IOException {
|
||||
final boolean getPOIs = types.contains(LocationType.POI);
|
||||
final String request = wrapJsonApiRequest("LocGeoPos",
|
||||
"{\"ring\":" //
|
||||
+ "{\"cCrd\":{\"x\":" + lon + ",\"y\":" + lat + "}}," //
|
||||
+ "\"getPOIs\":" + getPOIs + "}", //
|
||||
false);
|
||||
|
||||
final HttpUrl url = checkNotNull(mgateEndpoint);
|
||||
final CharSequence page = httpClient.get(url, request, "application/json");
|
||||
|
||||
try {
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
final String headErr = head.optString("err", null);
|
||||
if (headErr != null)
|
||||
throw new RuntimeException(headErr);
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT, head.getString("ver"), null, 0, null);
|
||||
|
||||
final JSONArray svcResList = head.getJSONArray("svcResL");
|
||||
checkState(svcResList.length() == 1);
|
||||
final JSONObject svcRes = svcResList.optJSONObject(0);
|
||||
checkState("LocGeoPos".equals(svcRes.getString("meth")));
|
||||
final String err = svcRes.getString("err");
|
||||
if (!"OK".equals(err)) {
|
||||
final String errTxt = svcRes.getString("errTxt");
|
||||
throw new RuntimeException(err + " " + errTxt);
|
||||
}
|
||||
final JSONObject res = svcRes.getJSONObject("res");
|
||||
|
||||
final JSONObject common = res.getJSONObject("common");
|
||||
/* final List<String[]> remarks = */ parseRemList(common.getJSONArray("remL"));
|
||||
|
||||
final JSONArray locL = res.optJSONArray("locL");
|
||||
final List<Location> locations;
|
||||
if (locL != null) {
|
||||
locations = parseLocList(locL);
|
||||
|
||||
// filter unwanted location types
|
||||
for (Iterator<Location> i = locations.iterator(); i.hasNext();) {
|
||||
final Location location = i.next();
|
||||
if (!types.contains(location.type))
|
||||
i.remove();
|
||||
}
|
||||
} else {
|
||||
locations = Collections.emptyList();
|
||||
}
|
||||
|
||||
return new NearbyLocationsResult(header, locations);
|
||||
} catch (final JSONException x) {
|
||||
throw new ParserException("cannot parse json: '" + page + "' on " + url, x);
|
||||
}
|
||||
}
|
||||
|
||||
protected final QueryDeparturesResult jsonStationBoard(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
final Calendar c = new GregorianCalendar(timeZone);
|
||||
c.setTime(time);
|
||||
final CharSequence jsonDate = jsonDate(c);
|
||||
final CharSequence jsonTime = jsonTime(c);
|
||||
final CharSequence normalizedStationId = normalizeStationId(stationId);
|
||||
final CharSequence stbFltrEquiv = Boolean.toString(!equivs);
|
||||
final CharSequence maxJny = Integer.toString(maxDepartures != 0 ? maxDepartures : DEFAULT_MAX_DEPARTURES);
|
||||
final CharSequence getPasslist = Boolean.toString(true); // traffic expensive
|
||||
final String request = wrapJsonApiRequest("StationBoard",
|
||||
"{\"type\":\"DEP\"," //
|
||||
+ "\"date\":\"" + jsonDate + "\"," //
|
||||
+ "\"time\":\"" + jsonTime + "\"," //
|
||||
+ "\"stbLoc\":{\"type\":\"S\"," + "\"state\":\"F\"," // F/M
|
||||
+ "\"extId\":" + JSONObject.quote(normalizedStationId.toString()) + "}," //
|
||||
+ "\"stbFltrEquiv\":" + stbFltrEquiv + ",\"maxJny\":" + maxJny + ",\"getPasslist\":"
|
||||
+ getPasslist + "}",
|
||||
false);
|
||||
|
||||
final HttpUrl url = checkNotNull(mgateEndpoint);
|
||||
final CharSequence page = httpClient.get(url, request, "application/json");
|
||||
|
||||
try {
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
final String headErr = head.optString("err", null);
|
||||
if (headErr != null)
|
||||
throw new RuntimeException(headErr);
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT, head.getString("ver"), null, 0, null);
|
||||
final QueryDeparturesResult result = new QueryDeparturesResult(header);
|
||||
|
||||
final JSONArray svcResList = head.getJSONArray("svcResL");
|
||||
checkState(svcResList.length() == 1);
|
||||
final JSONObject svcRes = svcResList.optJSONObject(0);
|
||||
checkState("StationBoard".equals(svcRes.getString("meth")));
|
||||
final String err = svcRes.getString("err");
|
||||
if (!"OK".equals(err)) {
|
||||
final String errTxt = svcRes.getString("errTxt");
|
||||
log.debug("Hafas error: {} {}", err, errTxt);
|
||||
if ("LOCATION".equals(err) && "HCI Service: location missing or invalid".equals(errTxt))
|
||||
return new QueryDeparturesResult(header, QueryDeparturesResult.Status.INVALID_STATION);
|
||||
if ("FAIL".equals(err) && "HCI Service: request failed".equals(errTxt))
|
||||
return new QueryDeparturesResult(header, QueryDeparturesResult.Status.SERVICE_DOWN);
|
||||
throw new RuntimeException(err + " " + errTxt);
|
||||
} else if ("1.10".equals(apiVersion) && svcRes.toString().length() == 170) {
|
||||
// horrible hack, because API version 1.10 doesn't signal invalid stations via error
|
||||
return new QueryDeparturesResult(header, QueryDeparturesResult.Status.INVALID_STATION);
|
||||
}
|
||||
final JSONObject res = svcRes.getJSONObject("res");
|
||||
|
||||
final JSONObject common = res.getJSONObject("common");
|
||||
/* final List<String[]> remarks = */ parseRemList(common.getJSONArray("remL"));
|
||||
final List<String> operators = parseOpList(common.getJSONArray("opL"));
|
||||
final List<Line> lines = parseProdList(common.getJSONArray("prodL"), operators);
|
||||
final JSONArray locList = common.getJSONArray("locL");
|
||||
final List<Location> locations = parseLocList(locList);
|
||||
|
||||
final JSONArray jnyList = res.optJSONArray("jnyL");
|
||||
if (jnyList != null) {
|
||||
for (int iJny = 0; iJny < jnyList.length(); iJny++) {
|
||||
final JSONObject jny = jnyList.getJSONObject(iJny);
|
||||
final JSONObject stbStop = jny.getJSONObject("stbStop");
|
||||
|
||||
final String stbStopPlatformS = stbStop.optString("dPlatfS", null);
|
||||
c.clear();
|
||||
ParserUtils.parseIsoDate(c, jny.getString("date"));
|
||||
final Date baseDate = c.getTime();
|
||||
|
||||
final Date plannedTime = parseJsonTime(c, baseDate, stbStop.getString("dTimeS"));
|
||||
|
||||
final Date predictedTime = parseJsonTime(c, baseDate, stbStop.optString("dTimeR", null));
|
||||
|
||||
final Line line = lines.get(stbStop.getInt("dProdX"));
|
||||
|
||||
final Location location = equivs ? locations.get(stbStop.getInt("locX"))
|
||||
: new Location(LocationType.STATION, stationId);
|
||||
final Position position = normalizePosition(stbStopPlatformS);
|
||||
|
||||
final String jnyDirTxt = jny.getString("dirTxt");
|
||||
final JSONArray stopList = jny.optJSONArray("stopL");
|
||||
final Location destination;
|
||||
if (stopList != null) {
|
||||
final int lastStopIdx = stopList.getJSONObject(stopList.length() - 1).getInt("locX");
|
||||
final String lastStopName = locList.getJSONObject(lastStopIdx).getString("name");
|
||||
if (jnyDirTxt.equals(lastStopName))
|
||||
destination = locations.get(lastStopIdx);
|
||||
else
|
||||
destination = new Location(LocationType.ANY, null, null, jnyDirTxt);
|
||||
} else {
|
||||
destination = new Location(LocationType.ANY, null, null, jnyDirTxt);
|
||||
}
|
||||
|
||||
final Departure departure = new Departure(plannedTime, predictedTime, line, position, destination,
|
||||
null, null);
|
||||
|
||||
StationDepartures stationDepartures = findStationDepartures(result.stationDepartures, location);
|
||||
if (stationDepartures == null) {
|
||||
stationDepartures = new StationDepartures(location, new ArrayList<Departure>(8), null);
|
||||
result.stationDepartures.add(stationDepartures);
|
||||
}
|
||||
|
||||
stationDepartures.departures.add(departure);
|
||||
}
|
||||
}
|
||||
|
||||
// sort departures
|
||||
for (final StationDepartures stationDepartures : result.stationDepartures)
|
||||
Collections.sort(stationDepartures.departures, Departure.TIME_COMPARATOR);
|
||||
|
||||
return result;
|
||||
} catch (final JSONException x) {
|
||||
throw new ParserException("cannot parse json: '" + page + "' on " + url, x);
|
||||
}
|
||||
}
|
||||
|
||||
protected final SuggestLocationsResult jsonLocMatch(final CharSequence constraint) throws IOException {
|
||||
final String request = wrapJsonApiRequest("LocMatch",
|
||||
"{\"input\":{\"field\":\"S\",\"loc\":{\"name\":" + JSONObject.quote(checkNotNull(constraint).toString())
|
||||
+ ",\"meta\":false},\"maxLoc\":" + DEFAULT_MAX_LOCATIONS + "}}",
|
||||
true);
|
||||
|
||||
final HttpUrl url = checkNotNull(mgateEndpoint);
|
||||
final CharSequence page = httpClient.get(url, request, "application/json");
|
||||
|
||||
try {
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
final String headErr = head.optString("err", null);
|
||||
if (headErr != null)
|
||||
throw new RuntimeException(headErr);
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT, head.getString("ver"), null, 0, null);
|
||||
|
||||
final JSONArray svcResList = head.getJSONArray("svcResL");
|
||||
checkState(svcResList.length() == 1);
|
||||
final JSONObject svcRes = svcResList.optJSONObject(0);
|
||||
checkState("LocMatch".equals(svcRes.getString("meth")));
|
||||
final String err = svcRes.getString("err");
|
||||
if (!"OK".equals(err)) {
|
||||
final String errTxt = svcRes.getString("errTxt");
|
||||
throw new RuntimeException(err + " " + errTxt);
|
||||
}
|
||||
final JSONObject res = svcRes.getJSONObject("res");
|
||||
|
||||
final JSONObject common = res.getJSONObject("common");
|
||||
/* final List<String[]> remarks = */ parseRemList(common.getJSONArray("remL"));
|
||||
|
||||
final JSONObject match = res.getJSONObject("match");
|
||||
final List<Location> locations = parseLocList(match.optJSONArray("locL"));
|
||||
final List<SuggestedLocation> suggestedLocations = new ArrayList<SuggestedLocation>(locations.size());
|
||||
for (final Location location : locations)
|
||||
suggestedLocations.add(new SuggestedLocation(location));
|
||||
// TODO weight
|
||||
|
||||
return new SuggestLocationsResult(header, suggestedLocations);
|
||||
} catch (final JSONException x) {
|
||||
throw new ParserException("cannot parse json: '" + page + "' on " + url, x);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Joiner JOINER = Joiner.on(' ').skipNulls();
|
||||
|
||||
protected final QueryTripsResult jsonTripSearch(Location from, @Nullable Location via, Location to, final Date time,
|
||||
final boolean dep, final @Nullable Set<Product> products, final String moreContext) throws IOException {
|
||||
if (!from.hasId() && from.hasName()) {
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||
final List<Location> locations = suggestLocations(JOINER.join(from.place, from.name)).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_FROM);
|
||||
if (locations.size() > 1)
|
||||
return new QueryTripsResult(header, locations, null, null);
|
||||
from = locations.get(0);
|
||||
}
|
||||
|
||||
if (via != null && !via.hasId() && via.hasName()) {
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||
final List<Location> locations = suggestLocations(JOINER.join(via.place, via.name)).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_VIA);
|
||||
if (locations.size() > 1)
|
||||
return new QueryTripsResult(header, locations, null, null);
|
||||
via = locations.get(0);
|
||||
}
|
||||
|
||||
if (!to.hasId() && to.hasName()) {
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||
final List<Location> locations = suggestLocations(JOINER.join(to.place, to.name)).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNKNOWN_TO);
|
||||
if (locations.size() > 1)
|
||||
return new QueryTripsResult(header, null, null, locations);
|
||||
to = locations.get(0);
|
||||
}
|
||||
|
||||
final Calendar c = new GregorianCalendar(timeZone);
|
||||
c.setTime(time);
|
||||
final CharSequence outDate = jsonDate(c);
|
||||
final CharSequence outTime = jsonTime(c);
|
||||
final CharSequence outFrwdKey = "1.11".equals(apiVersion) ? "outFrwd" : "frwd";
|
||||
final CharSequence outFrwd = Boolean.toString(dep);
|
||||
final CharSequence jnyFltr = productsString(products);
|
||||
final CharSequence jsonContext = moreContext != null ? "\"ctxScr\":" + JSONObject.quote(moreContext) + "," : "";
|
||||
final String request = wrapJsonApiRequest("TripSearch", "{" //
|
||||
+ jsonContext //
|
||||
+ "\"depLocL\":[" + jsonLocation(from) + "]," //
|
||||
+ "\"arrLocL\":[" + jsonLocation(to) + "]," //
|
||||
+ (via != null ? "\"viaLocL\":[{\"loc\":" + jsonLocation(via) + "}]," : "") //
|
||||
+ "\"outDate\":\"" + outDate + "\"," //
|
||||
+ "\"outTime\":\"" + outTime + "\"," //
|
||||
+ "\"" + outFrwdKey + "\":" + outFrwd + "," //
|
||||
+ "\"jnyFltrL\":[{\"value\":\"" + jnyFltr + "\",\"mode\":\"BIT\",\"type\":\"PROD\"}]," //
|
||||
+ "\"gisFltrL\":[{\"mode\":\"FB\",\"profile\":{\"type\":\"F\",\"linDistRouting\":false,\"maxdist\":2000},\"type\":\"P\"}]," //
|
||||
+ "\"getPolyline\":false,\"getPasslist\":true,\"getIST\":false,\"getEco\":false,\"extChgTime\":-1}", //
|
||||
false);
|
||||
|
||||
final HttpUrl url = checkNotNull(mgateEndpoint);
|
||||
final CharSequence page = httpClient.get(url, request, "application/json");
|
||||
|
||||
try {
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
final String headErr = head.optString("err", null);
|
||||
if (headErr != null)
|
||||
throw new RuntimeException(headErr);
|
||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT, head.getString("ver"), null, 0, null);
|
||||
|
||||
final JSONArray svcResList = head.getJSONArray("svcResL");
|
||||
checkState(svcResList.length() == 1);
|
||||
final JSONObject svcRes = svcResList.optJSONObject(0);
|
||||
checkState("TripSearch".equals(svcRes.getString("meth")));
|
||||
final String err = svcRes.getString("err");
|
||||
if (!"OK".equals(err)) {
|
||||
final String errTxt = svcRes.getString("errTxt");
|
||||
log.debug("Hafas error: {} {}", err, errTxt);
|
||||
if ("H890".equals(err)) // No connections found.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
if ("H891".equals(err)) // No route found (try entering an intermediate station).
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS);
|
||||
if ("H895".equals(err)) // Departure/Arrival are too near.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.TOO_CLOSE);
|
||||
if ("H9220".equals(err)) // Nearby to the given address stations could not be found.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.UNRESOLVABLE_ADDRESS);
|
||||
if ("H9360".equals(err)) // Date outside of the timetable period.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.INVALID_DATE);
|
||||
if ("H9380".equals(err)) // Departure/Arrival/Intermediate or equivalent stations def'd more
|
||||
// than once.
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.TOO_CLOSE);
|
||||
if ("FAIL".equals(err) && "HCI Service: request failed".equals(errTxt))
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.SERVICE_DOWN);
|
||||
throw new RuntimeException(err + " " + errTxt);
|
||||
}
|
||||
final JSONObject res = svcRes.getJSONObject("res");
|
||||
|
||||
final JSONObject common = res.getJSONObject("common");
|
||||
/* final List<String[]> remarks = */ parseRemList(common.getJSONArray("remL"));
|
||||
final List<Location> locations = parseLocList(common.getJSONArray("locL"));
|
||||
final List<String> operators = parseOpList(common.getJSONArray("opL"));
|
||||
final List<Line> lines = parseProdList(common.getJSONArray("prodL"), operators);
|
||||
|
||||
final JSONArray outConList = res.optJSONArray("outConL");
|
||||
final List<Trip> trips = new ArrayList<Trip>(outConList.length());
|
||||
for (int iOutCon = 0; iOutCon < outConList.length(); iOutCon++) {
|
||||
final JSONObject outCon = outConList.getJSONObject(iOutCon);
|
||||
final Location tripFrom = locations.get(outCon.getJSONObject("dep").getInt("locX"));
|
||||
final Location tripTo = locations.get(outCon.getJSONObject("arr").getInt("locX"));
|
||||
|
||||
c.clear();
|
||||
ParserUtils.parseIsoDate(c, outCon.getString("date"));
|
||||
final Date baseDate = c.getTime();
|
||||
|
||||
final JSONArray secList = outCon.optJSONArray("secL");
|
||||
final List<Trip.Leg> legs = new ArrayList<Trip.Leg>(secList.length());
|
||||
for (int iSec = 0; iSec < secList.length(); iSec++) {
|
||||
final JSONObject sec = secList.getJSONObject(iSec);
|
||||
final String secType = sec.getString("type");
|
||||
|
||||
final JSONObject secDep = sec.getJSONObject("dep");
|
||||
final Stop departureStop = parseJsonStop(secDep, locations, c, baseDate);
|
||||
|
||||
final JSONObject secArr = sec.getJSONObject("arr");
|
||||
final Stop arrivalStop = parseJsonStop(secArr, locations, c, baseDate);
|
||||
|
||||
final Trip.Leg leg;
|
||||
if ("JNY".equals(secType)) {
|
||||
final JSONObject jny = sec.getJSONObject("jny");
|
||||
final Line line = lines.get(jny.getInt("prodX"));
|
||||
final String dirTxt = jny.optString("dirTxt", null);
|
||||
final Location destination = dirTxt != null ? new Location(LocationType.ANY, null, null, dirTxt)
|
||||
: null;
|
||||
|
||||
final JSONArray stopList = jny.getJSONArray("stopL");
|
||||
checkState(stopList.length() >= 2);
|
||||
final List<Stop> intermediateStops = new ArrayList<Stop>(stopList.length());
|
||||
for (int iStop = 1; iStop < stopList.length() - 1; iStop++) {
|
||||
final JSONObject stop = stopList.getJSONObject(iStop);
|
||||
final Stop intermediateStop = parseJsonStop(stop, locations, c, baseDate);
|
||||
intermediateStops.add(intermediateStop);
|
||||
}
|
||||
|
||||
leg = new Trip.Public(line, destination, departureStop, arrivalStop, intermediateStops, null,
|
||||
null);
|
||||
} else if ("WALK".equals(secType) || "TRSF".equals(secType)) {
|
||||
final JSONObject gis = sec.getJSONObject("gis");
|
||||
final int distance = gis.optInt("dist", 0);
|
||||
leg = new Trip.Individual(Trip.Individual.Type.WALK, departureStop.location,
|
||||
departureStop.getDepartureTime(), arrivalStop.location, arrivalStop.getArrivalTime(),
|
||||
null, distance);
|
||||
} else {
|
||||
throw new IllegalStateException("cannot handle type: " + secType);
|
||||
}
|
||||
|
||||
legs.add(leg);
|
||||
}
|
||||
|
||||
final JSONObject trfRes = outCon.optJSONObject("trfRes");
|
||||
final List<Fare> fares = new LinkedList<Fare>();
|
||||
if (trfRes != null) {
|
||||
final JSONArray fareSetList = trfRes.getJSONArray("fareSetL");
|
||||
for (int iFareSet = 0; iFareSet < fareSetList.length(); iFareSet++) {
|
||||
final JSONObject fareSet = fareSetList.getJSONObject(iFareSet);
|
||||
final String fareSetName = fareSet.optString("name", null);
|
||||
final String fareSetDescription = fareSet.optString("desc", null);
|
||||
if (fareSetName != null || fareSetDescription != null) {
|
||||
final JSONArray fareList = fareSet.getJSONArray("fareL");
|
||||
for (int iFare = 0; iFare < fareList.length(); iFare++) {
|
||||
final JSONObject jsonFare = fareList.getJSONObject(iFare);
|
||||
final String name = jsonFare.getString("name");
|
||||
final Currency currency = Currency.getInstance(jsonFare.getString("cur"));
|
||||
final float price = jsonFare.getInt("prc") / 100f;
|
||||
final Fare fare = parseJsonTripFare(fareSetName, fareSetDescription, name, currency,
|
||||
price);
|
||||
if (fare != null)
|
||||
fares.add(fare);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Trip trip = new Trip(null, tripFrom, tripTo, legs, fares, null, null);
|
||||
trips.add(trip);
|
||||
}
|
||||
|
||||
final JsonContext context = new JsonContext(from, via, to, time, dep, products, res.optString("outCtxScrF"),
|
||||
res.optString("outCtxScrB"));
|
||||
return new QueryTripsResult(header, null, from, null, to, context, trips);
|
||||
} catch (final JSONException x) {
|
||||
throw new ParserException("cannot parse json: '" + page + "' on " + url, x);
|
||||
}
|
||||
}
|
||||
|
||||
protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription,
|
||||
final String name, final Currency currency, final float price) {
|
||||
if (name.endsWith("- Jahreskarte") || name.endsWith("- Monatskarte"))
|
||||
return null;
|
||||
if (name.startsWith("Vollpreis - "))
|
||||
return new Fare(fareSetName, Fare.Type.ADULT, currency, price, name.substring(12), null);
|
||||
if (name.startsWith("Kind - "))
|
||||
return new Fare(fareSetName, Fare.Type.CHILD, currency, price, name.substring(7), null);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String wrapJsonApiRequest(final String meth, final String req, final boolean formatted) {
|
||||
return "{" //
|
||||
+ "\"auth\":" + checkNotNull(apiAuthorization) + "," //
|
||||
+ "\"client\":" + checkNotNull(apiClient) + "," //
|
||||
+ "\"ver\":\"" + checkNotNull(apiVersion) + "\",\"lang\":\"eng\"," //
|
||||
+ "\"svcReqL\":[{\"cfg\":{\"polyEnc\":\"GPA\"},\"meth\":\"" + meth + "\",\"req\":" + req + "}]," //
|
||||
+ "\"formatted\":" + formatted + "}";
|
||||
}
|
||||
|
||||
private String jsonLocation(final Location location) {
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
return "{\"type\":\"S\",\"extId\":" + JSONObject.quote(location.id) + "}";
|
||||
else if (location.type == LocationType.ADDRESS && location.hasId())
|
||||
return "{\"type\":\"A\",\"lid\":" + JSONObject.quote(location.id) + "}";
|
||||
else if (location.type == LocationType.POI && location.hasId())
|
||||
return "{\"type\":\"P\",\"lid\":" + JSONObject.quote(location.id) + "}";
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
private CharSequence jsonDate(final Calendar time) {
|
||||
final int year = time.get(Calendar.YEAR);
|
||||
final int month = time.get(Calendar.MONTH) + 1;
|
||||
final int day = time.get(Calendar.DAY_OF_MONTH);
|
||||
return String.format(Locale.ENGLISH, "%04d%02d%02d", year, month, day);
|
||||
}
|
||||
|
||||
private CharSequence jsonTime(final Calendar time) {
|
||||
final int hour = time.get(Calendar.HOUR_OF_DAY);
|
||||
final int minute = time.get(Calendar.MINUTE);
|
||||
return String.format(Locale.ENGLISH, "%02d%02d00", hour, minute);
|
||||
}
|
||||
|
||||
private static final Pattern P_JSON_TIME = Pattern.compile("(\\d{2})?(\\d{2})(\\d{2})(\\d{2})");
|
||||
|
||||
private final Date parseJsonTime(final Calendar calendar, final Date baseDate, final CharSequence str) {
|
||||
if (str == null)
|
||||
return null;
|
||||
|
||||
final Matcher m = P_JSON_TIME.matcher(str);
|
||||
if (m.matches()) {
|
||||
calendar.setTime(baseDate);
|
||||
|
||||
if (m.group(1) != null)
|
||||
calendar.add(Calendar.DAY_OF_YEAR, Integer.parseInt(m.group(1)));
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(m.group(2)));
|
||||
calendar.set(Calendar.MINUTE, Integer.parseInt(m.group(3)));
|
||||
calendar.set(Calendar.SECOND, Integer.parseInt(m.group(4)));
|
||||
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
throw new RuntimeException("cannot parse: '" + str + "'");
|
||||
}
|
||||
|
||||
private Stop parseJsonStop(final JSONObject json, final List<Location> locations, final Calendar c,
|
||||
final Date baseDate) throws JSONException {
|
||||
final Location location = locations.get(json.getInt("locX"));
|
||||
|
||||
final boolean arrivalCancelled = json.optBoolean("aCncl", false);
|
||||
final Date plannedArrivalTime = parseJsonTime(c, baseDate, json.optString("aTimeS", null));
|
||||
final Date predictedArrivalTime = parseJsonTime(c, baseDate, json.optString("aTimeR", null));
|
||||
final Position plannedArrivalPosition = normalizePosition(json.optString("aPlatfS", null));
|
||||
final Position predictedArrivalPosition = normalizePosition(json.optString("aPlatfR", null));
|
||||
|
||||
final boolean departureCancelled = json.optBoolean("dCncl", false);
|
||||
final Date plannedDepartureTime = parseJsonTime(c, baseDate, json.optString("dTimeS", null));
|
||||
final Date predictedDepartureTime = parseJsonTime(c, baseDate, json.optString("dTimeR", null));
|
||||
final Position plannedDeparturePosition = normalizePosition(json.optString("dPlatfS", null));
|
||||
final Position predictedDeparturePosition = normalizePosition(json.optString("dPlatfR", null));
|
||||
|
||||
return new Stop(location, plannedArrivalTime, predictedArrivalTime, plannedArrivalPosition,
|
||||
predictedArrivalPosition, arrivalCancelled, plannedDepartureTime, predictedDepartureTime,
|
||||
plannedDeparturePosition, predictedDeparturePosition, departureCancelled);
|
||||
}
|
||||
|
||||
private List<String[]> parseRemList(final JSONArray remList) throws JSONException {
|
||||
final List<String[]> remarks = new ArrayList<String[]>(remList.length());
|
||||
|
||||
for (int i = 0; i < remList.length(); i++) {
|
||||
final JSONObject rem = remList.getJSONObject(i);
|
||||
final String code = rem.getString("code");
|
||||
final String txt = rem.getString("txtN");
|
||||
remarks.add(new String[] { code, txt });
|
||||
}
|
||||
|
||||
return remarks;
|
||||
}
|
||||
|
||||
private List<Location> parseLocList(final JSONArray locList) throws JSONException {
|
||||
final List<Location> locations = new ArrayList<Location>(locList.length());
|
||||
|
||||
for (int iLoc = 0; iLoc < locList.length(); iLoc++) {
|
||||
final JSONObject loc = locList.getJSONObject(iLoc);
|
||||
final String type = loc.getString("type");
|
||||
|
||||
final LocationType locationType;
|
||||
final String id;
|
||||
final String[] placeAndName;
|
||||
final Set<Product> products;
|
||||
if ("S".equals(type)) {
|
||||
locationType = LocationType.STATION;
|
||||
id = normalizeStationId(loc.getString("extId"));
|
||||
placeAndName = splitStationName(loc.getString("name"));
|
||||
final int pCls = loc.optInt("pCls", -1);
|
||||
products = pCls != -1 ? intToProducts(pCls) : null;
|
||||
} else if ("P".equals(type)) {
|
||||
locationType = LocationType.POI;
|
||||
id = loc.getString("lid");
|
||||
placeAndName = splitPOI(loc.getString("name"));
|
||||
products = null;
|
||||
} else if ("A".equals(type)) {
|
||||
locationType = LocationType.ADDRESS;
|
||||
id = loc.getString("lid");
|
||||
placeAndName = splitAddress(loc.getString("name"));
|
||||
products = null;
|
||||
} else {
|
||||
throw new RuntimeException("Unknown type " + type + ": " + loc);
|
||||
}
|
||||
|
||||
final JSONObject crd = loc.optJSONObject("crd");
|
||||
if (crd != null)
|
||||
locations.add(new Location(locationType, id, crd.getInt("y"), crd.getInt("x"), placeAndName[0],
|
||||
placeAndName[1], products));
|
||||
else
|
||||
locations.add(new Location(LocationType.STATION, id, null, placeAndName[0], placeAndName[1], products));
|
||||
}
|
||||
|
||||
return locations;
|
||||
}
|
||||
|
||||
private List<String> parseOpList(final JSONArray opList) throws JSONException {
|
||||
final List<String> operators = new ArrayList<String>(opList.length());
|
||||
|
||||
for (int i = 0; i < opList.length(); i++) {
|
||||
final JSONObject op = opList.getJSONObject(i);
|
||||
final String operator = op.getString("name");
|
||||
operators.add(operator);
|
||||
}
|
||||
|
||||
return operators;
|
||||
}
|
||||
|
||||
private List<Line> parseProdList(final JSONArray prodList, final List<String> operators) throws JSONException {
|
||||
final List<Line> lines = new ArrayList<Line>(prodList.length());
|
||||
|
||||
for (int iProd = 0; iProd < prodList.length(); iProd++) {
|
||||
final JSONObject prod = prodList.getJSONObject(iProd);
|
||||
final int oprIndex = prod.optInt("oprX", -1);
|
||||
final String operator = oprIndex != -1 ? operators.get(oprIndex) : null;
|
||||
final int cls = prod.optInt("cls", -1);
|
||||
final Product product = cls != -1 ? intToProduct(cls) : null;
|
||||
final String name = prod.getString("name");
|
||||
lines.add(newLine(operator, product, name));
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
protected Line newLine(final String operator, final Product product, final String name) {
|
||||
final String normalizedName;
|
||||
if (product == Product.BUS && name.startsWith("Bus "))
|
||||
normalizedName = name.substring(4);
|
||||
else if (product == Product.TRAM && name.startsWith("Tram "))
|
||||
normalizedName = name.substring(5);
|
||||
else if (product == Product.SUBURBAN_TRAIN && name.startsWith("S "))
|
||||
normalizedName = "S" + name.substring(2);
|
||||
else
|
||||
normalizedName = name;
|
||||
return new Line(null, operator, product, normalizedName, lineStyle(operator, product, normalizedName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class JsonContext implements QueryTripsContext {
|
||||
public final Location from, via, to;
|
||||
public final Date date;
|
||||
public final boolean dep;
|
||||
public final Set<Product> products;
|
||||
public final String laterContext, earlierContext;
|
||||
|
||||
public JsonContext(final Location from, final @Nullable Location via, final Location to, final Date date,
|
||||
final boolean dep, final Set<Product> products, final String laterContext,
|
||||
final String earlierContext) {
|
||||
this.from = from;
|
||||
this.via = via;
|
||||
this.to = to;
|
||||
this.date = date;
|
||||
this.dep = dep;
|
||||
this.products = products;
|
||||
this.laterContext = laterContext;
|
||||
this.earlierContext = earlierContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canQueryLater() {
|
||||
return laterContext != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canQueryEarlier() {
|
||||
return earlierContext != null;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -28,7 +28,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public final class BahnProvider extends AbstractHafasProvider {
|
||||
public final class BahnProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://reiseauskunft.bahn.de/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.HIGH_SPEED_TRAIN,
|
||||
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
|
||||
|
|
|
@ -36,7 +36,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public final class BvgProvider extends AbstractHafasProvider {
|
||||
public final class BvgProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("http://bvg-apps.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 };
|
||||
|
|
|
@ -27,7 +27,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class DsbProvider extends AbstractHafasProvider {
|
||||
public class DsbProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("http://mobil.rejseplanen.dk/mobil-bin/");
|
||||
// http://dk.hafas.de/bin/fat/
|
||||
// http://mobil.rejseplanen.dk/mobil-bin/
|
||||
|
|
|
@ -38,7 +38,7 @@ import okhttp3.HttpUrl;
|
|||
*
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class EireannProvider extends AbstractHafasProvider {
|
||||
public class EireannProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("http://journeyplanner.buseireann.ie/jp/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { null, null, null, Product.BUS };
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class InvgProvider extends AbstractHafasProvider {
|
||||
public class InvgProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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 };
|
||||
|
|
|
@ -28,7 +28,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class LuProvider extends AbstractHafasProvider {
|
||||
public class LuProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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,
|
||||
|
|
|
@ -34,7 +34,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class NasaProvider extends AbstractHafasProvider {
|
||||
public class NasaProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://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,
|
||||
|
|
|
@ -35,7 +35,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class NriProvider extends AbstractHafasProvider {
|
||||
public class NriProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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 };
|
||||
|
|
|
@ -32,7 +32,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class NsProvider extends AbstractHafasProvider {
|
||||
public class NsProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://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,
|
||||
|
|
|
@ -34,7 +34,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class NvvProvider extends AbstractHafasProvider {
|
||||
public class NvvProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://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,
|
||||
|
|
|
@ -32,7 +32,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class OebbProvider extends AbstractHafasProvider {
|
||||
public class OebbProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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,
|
||||
|
|
|
@ -17,44 +17,28 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class OoevvProvider extends AbstractHafasProvider {
|
||||
public class OoevvProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://verkehrsauskunft.ooevv.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public OoevvProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.OOEVV, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_ooevv\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public OoevvProvider(final String apiAuthorization) {
|
||||
super(NetworkId.OOEVV, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_ooevv\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
httpClient.setSslAcceptAllHostnames(true);
|
||||
}
|
||||
|
||||
|
@ -91,39 +75,4 @@ public class OoevvProvider extends AbstractHafasProvider {
|
|||
|
||||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class PlProvider extends AbstractHafasProvider {
|
||||
public class PlProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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 };
|
||||
|
|
|
@ -27,7 +27,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class RtProvider extends AbstractHafasProvider {
|
||||
public class RtProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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,
|
||||
|
|
|
@ -27,7 +27,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SbbProvider extends AbstractHafasProvider {
|
||||
public class SbbProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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,
|
||||
|
|
|
@ -31,7 +31,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SeProvider extends AbstractHafasProvider {
|
||||
public class SeProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://reseplanerare.resrobot.se/bin/");
|
||||
// http://samtrafiken.hafas.de/bin/
|
||||
// http://reseplanerare.resrobot.se/bin/
|
||||
|
|
|
@ -56,7 +56,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SeptaProvider extends AbstractHafasProvider {
|
||||
public class SeptaProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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;
|
||||
|
|
|
@ -17,49 +17,34 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Fare;
|
||||
import de.schildbach.pte.dto.Fare.Type;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class ShProvider extends AbstractHafasProvider {
|
||||
public class ShProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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(final String jsonApiAuthorization) {
|
||||
super(NetworkId.SH, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.10");
|
||||
setJsonApiClient("{\"id\":\"NAHSH\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public ShProvider(final String apiAuthorization) {
|
||||
super(NetworkId.SH, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.10");
|
||||
setApiClient("{\"id\":\"NAHSH\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
|
@ -92,41 +77,6 @@ public class ShProvider extends AbstractHafasProvider {
|
|||
return super.splitStationName(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Fare parseJsonTripFare(final @Nullable String fareSetName, final @Nullable String fareSetDescription,
|
||||
String name, final Currency currency, final float price) {
|
||||
|
|
|
@ -34,7 +34,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SncbProvider extends AbstractHafasProvider {
|
||||
public class SncbProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://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,
|
||||
|
|
|
@ -17,47 +17,31 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SvvProvider extends AbstractHafasProvider {
|
||||
public class SvvProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://fahrplan.salzburg-verkehr.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public SvvProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.SVV, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_svv\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public SvvProvider(final String apiAuthorization) {
|
||||
super(NetworkId.SVV, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_svv\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
setStyles(STYLES);
|
||||
httpClient.setTrustAllCertificates(true);
|
||||
}
|
||||
|
@ -96,41 +80,6 @@ public class SvvProvider extends AbstractHafasProvider {
|
|||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
|
||||
|
||||
static {
|
||||
|
|
|
@ -17,47 +17,31 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VaoProvider extends AbstractHafasProvider {
|
||||
public class VaoProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://app.verkehrsauskunft.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public VaoProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.VAO, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public VaoProvider(final String apiAuthorization) {
|
||||
super(NetworkId.VAO, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
|
@ -95,41 +79,6 @@ public class VaoProvider extends AbstractHafasProvider {
|
|||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
|
||||
|
||||
static {
|
||||
|
|
|
@ -32,7 +32,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VbbProvider extends AbstractHafasProvider {
|
||||
public class VbbProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("http://fahrinfo.vbb.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 };
|
||||
|
|
|
@ -17,35 +17,21 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.Style.Shape;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VbnProvider extends AbstractHafasProvider {
|
||||
public class VbnProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://fahrplaner.vbn.de/hafas/");
|
||||
// http://fahrplaner.vsninfo.de/hafas/
|
||||
// http://fahrplan.rsag-online.de/hafas/
|
||||
|
@ -55,13 +41,11 @@ public class VbnProvider extends AbstractHafasProvider {
|
|||
Product.REGIONAL_TRAIN, Product.REGIONAL_TRAIN, Product.SUBURBAN_TRAIN, Product.BUS, Product.FERRY,
|
||||
Product.SUBWAY, Product.TRAM, Product.ON_DEMAND };
|
||||
|
||||
public VbnProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.VBN, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.10");
|
||||
setJsonApiClient("{\"id\":\"VBN\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public VbnProvider(final String apiAuthorization) {
|
||||
super(NetworkId.VBN, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.10");
|
||||
setApiClient("{\"id\":\"VBN\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
|
@ -92,41 +76,6 @@ public class VbnProvider extends AbstractHafasProvider {
|
|||
return Product.ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
|
||||
|
||||
static {
|
||||
|
|
|
@ -31,7 +31,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VgsProvider extends AbstractHafasProvider {
|
||||
public class VgsProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("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,
|
||||
|
|
|
@ -17,44 +17,28 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VmobilProvider extends AbstractHafasProvider {
|
||||
public class VmobilProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://fahrplan.vmobil.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public VmobilProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.VMOBIL, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public VmobilProvider(final String apiAuthorization) {
|
||||
super(NetworkId.VMOBIL, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvv\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
httpClient.setSslAcceptAllHostnames(true);
|
||||
}
|
||||
|
||||
|
@ -91,39 +75,4 @@ public class VmobilProvider extends AbstractHafasProvider {
|
|||
|
||||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,47 +17,31 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VorProvider extends AbstractHafasProvider {
|
||||
public class VorProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://anachb.vor.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public VorProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.VOR, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_anachb\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public VorProvider(final String apiAuthorization) {
|
||||
super(NetworkId.VOR, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_anachb\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
setStyles(STYLES);
|
||||
}
|
||||
|
||||
|
@ -95,41 +79,6 @@ public class VorProvider extends AbstractHafasProvider {
|
|||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
|
||||
private static final Map<String, Style> STYLES = new HashMap<String, Style>();
|
||||
|
||||
static {
|
||||
|
|
|
@ -17,44 +17,28 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class VvtProvider extends AbstractHafasProvider {
|
||||
public class VvtProvider extends AbstractHafasMobileProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://fahrplan.vvt.at/bin/");
|
||||
private static final Product[] PRODUCTS_MAP = { Product.HIGH_SPEED_TRAIN, Product.SUBURBAN_TRAIN, Product.SUBWAY,
|
||||
null, Product.TRAM, Product.REGIONAL_TRAIN, Product.BUS, Product.BUS, Product.TRAM, Product.FERRY,
|
||||
Product.ON_DEMAND, Product.BUS, Product.REGIONAL_TRAIN, null, null, null };
|
||||
|
||||
public VvtProvider(final String jsonApiAuthorization) {
|
||||
super(NetworkId.VVT, API_BASE, "dn", PRODUCTS_MAP);
|
||||
|
||||
setJsonApiVersion("1.11");
|
||||
setJsonApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvt\",\"type\":\"AND\"}");
|
||||
setJsonApiAuthorization(jsonApiAuthorization);
|
||||
setJsonNearbyLocationsEncoding(Charsets.UTF_8);
|
||||
public VvtProvider(final String apiAuthorization) {
|
||||
super(NetworkId.VVT, API_BASE, PRODUCTS_MAP);
|
||||
setApiVersion("1.11");
|
||||
setApiClient("{\"id\":\"VAO\",\"l\":\"vs_vvt\",\"type\":\"AND\"}");
|
||||
setApiAuthorization(apiAuthorization);
|
||||
httpClient.setSslAcceptAllHostnames(true);
|
||||
}
|
||||
|
||||
|
@ -91,39 +75,4 @@ public class VvtProvider extends AbstractHafasProvider {
|
|||
|
||||
return super.splitAddress(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyLocationsResult queryNearbyLocations(final EnumSet<LocationType> types, final Location location,
|
||||
final int maxDistance, final int maxLocations) throws IOException {
|
||||
if (location.hasLocation())
|
||||
return jsonLocGeoPos(types, location.lat, location.lon);
|
||||
else
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time,
|
||||
final int maxDepartures, final boolean equivs) throws IOException {
|
||||
return jsonStationBoard(stationId, time, maxDepartures, equivs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestLocationsResult suggestLocations(final CharSequence constraint) throws IOException {
|
||||
return jsonLocMatch(constraint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
||||
return jsonTripSearch(from, via, to, date, dep, products, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later) throws IOException {
|
||||
final JsonContext jsonContext = (JsonContext) context;
|
||||
return jsonTripSearch(jsonContext.from, jsonContext.via, jsonContext.to, jsonContext.date, jsonContext.dep,
|
||||
jsonContext.products, later ? jsonContext.laterContext : jsonContext.earlierContext);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import okhttp3.HttpUrl;
|
|||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class ZvvProvider extends AbstractHafasProvider {
|
||||
public class ZvvProvider extends AbstractHafasLegacyProvider {
|
||||
private static final HttpUrl API_BASE = HttpUrl.parse("https://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,
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class OoevvProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public OoevvProviderLiveTest() {
|
||||
super(new OoevvProvider(secretProperty("ooevv.json_api_authorization")));
|
||||
super(new OoevvProvider(secretProperty("ooevv.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -40,7 +40,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class ShProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public ShProviderLiveTest() {
|
||||
super(new ShProvider(secretProperty("sh.json_api_authorization")));
|
||||
super(new ShProvider(secretProperty("sh.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class SvvProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public SvvProviderLiveTest() {
|
||||
super(new SvvProvider(secretProperty("svv.json_api_authorization")));
|
||||
super(new SvvProvider(secretProperty("svv.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class VaoProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public VaoProviderLiveTest() {
|
||||
super(new VaoProvider(secretProperty("vao.json_api_authorization")));
|
||||
super(new VaoProvider(secretProperty("vao.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class VbnProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public VbnProviderLiveTest() {
|
||||
super(new VbnProvider(secretProperty("vbn.json_api_authorization")));
|
||||
super(new VbnProvider(secretProperty("vbn.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class VmobilProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public VmobilProviderLiveTest() {
|
||||
super(new VmobilProvider(secretProperty("vmobil.json_api_authorization")));
|
||||
super(new VmobilProvider(secretProperty("vmobil.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class VorProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public VorProviderLiveTest() {
|
||||
super(new VorProvider(secretProperty("vor.json_api_authorization")));
|
||||
super(new VorProvider(secretProperty("vor.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -42,7 +42,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
|||
*/
|
||||
public class VvtProviderLiveTest extends AbstractProviderLiveTest {
|
||||
public VvtProviderLiveTest() {
|
||||
super(new VvtProvider(secretProperty("vvt.json_api_authorization")));
|
||||
super(new VvtProvider(secretProperty("vvt.api_authorization")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
# Secrets are needed to run some of the live tests.
|
||||
vgn.api_base =
|
||||
navitia.authorization =
|
||||
vbn.json_api_authorization =
|
||||
sh.json_api_authorization =
|
||||
vao.json_api_authorization =
|
||||
vbn.api_authorization =
|
||||
sh.api_authorization =
|
||||
vor.api_authorization =
|
||||
ooevv.api_authorization =
|
||||
svv.api_authorization =
|
||||
vvt.api_authorization =
|
||||
vmobil.api_authorization =
|
||||
vao.api_authorization =
|
||||
hsl.usertoken =
|
||||
hsl.passphrase =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue