mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 19:38:49 +00:00
NetworkProvider: queryTrips() now uses a TripOptions field for products, optimize, walkSpeed, accessibilty and options.
The old queryTrips() variant is now deprecated.
This commit is contained in:
parent
af94ee8724
commit
79ff93b80f
23 changed files with 263 additions and 208 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,7 +24,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -75,6 +74,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
import de.schildbach.pte.dto.Trip.Leg;
|
import de.schildbach.pte.dto.Trip.Leg;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.InvalidDataException;
|
import de.schildbach.pte.exception.InvalidDataException;
|
||||||
import de.schildbach.pte.exception.ParserException;
|
import de.schildbach.pte.exception.ParserException;
|
||||||
import de.schildbach.pte.util.HttpClient;
|
import de.schildbach.pte.util.HttpClient;
|
||||||
|
@ -1970,9 +1970,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
@Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
appendCommonRequestParams(url, "XML");
|
appendCommonRequestParams(url, "XML");
|
||||||
|
|
||||||
url.addEncodedQueryParameter("sessionID", "0");
|
url.addEncodedQueryParameter("sessionID", "0");
|
||||||
|
@ -1994,29 +1992,32 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
url.addEncodedQueryParameter("ptOptionsActive", "1"); // enable public transport options
|
url.addEncodedQueryParameter("ptOptionsActive", "1"); // enable public transport options
|
||||||
url.addEncodedQueryParameter("itOptionsActive", "1"); // enable individual transport options
|
url.addEncodedQueryParameter("itOptionsActive", "1"); // enable individual transport options
|
||||||
|
|
||||||
if (optimize == Optimize.LEAST_DURATION)
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
|
if (options.optimize == Optimize.LEAST_DURATION)
|
||||||
url.addEncodedQueryParameter("routeType", "LEASTTIME");
|
url.addEncodedQueryParameter("routeType", "LEASTTIME");
|
||||||
else if (optimize == Optimize.LEAST_CHANGES)
|
else if (options.optimize == Optimize.LEAST_CHANGES)
|
||||||
url.addEncodedQueryParameter("routeType", "LEASTINTERCHANGE");
|
url.addEncodedQueryParameter("routeType", "LEASTINTERCHANGE");
|
||||||
else if (optimize == Optimize.LEAST_WALKING)
|
else if (options.optimize == Optimize.LEAST_WALKING)
|
||||||
url.addEncodedQueryParameter("routeType", "LEASTWALKING");
|
url.addEncodedQueryParameter("routeType", "LEASTWALKING");
|
||||||
else if (optimize != null)
|
else if (options.optimize != null)
|
||||||
log.info("Cannot handle " + optimize + ", ignoring.");
|
log.info("Cannot handle " + options.optimize + ", ignoring.");
|
||||||
|
|
||||||
url.addEncodedQueryParameter("changeSpeed", WALKSPEED_MAP.get(walkSpeed));
|
url.addEncodedQueryParameter("changeSpeed", WALKSPEED_MAP.get(options.walkSpeed));
|
||||||
|
|
||||||
if (accessibility == Accessibility.BARRIER_FREE)
|
if (options.accessibility == Accessibility.BARRIER_FREE)
|
||||||
url.addEncodedQueryParameter("imparedOptionsActive", "1").addEncodedQueryParameter("wheelchair", "on")
|
url.addEncodedQueryParameter("imparedOptionsActive", "1").addEncodedQueryParameter("wheelchair", "on")
|
||||||
.addEncodedQueryParameter("noSolidStairs", "on");
|
.addEncodedQueryParameter("noSolidStairs", "on");
|
||||||
else if (accessibility == Accessibility.LIMITED)
|
else if (options.accessibility == Accessibility.LIMITED)
|
||||||
url.addEncodedQueryParameter("imparedOptionsActive", "1").addEncodedQueryParameter("wheelchair", "on")
|
url.addEncodedQueryParameter("imparedOptionsActive", "1").addEncodedQueryParameter("wheelchair", "on")
|
||||||
.addEncodedQueryParameter("lowPlatformVhcl", "on").addEncodedQueryParameter("noSolidStairs", "on");
|
.addEncodedQueryParameter("lowPlatformVhcl", "on").addEncodedQueryParameter("noSolidStairs", "on");
|
||||||
|
|
||||||
if (products != null) {
|
if (options.products != null) {
|
||||||
url.addEncodedQueryParameter("includedMeans", "checkbox");
|
url.addEncodedQueryParameter("includedMeans", "checkbox");
|
||||||
|
|
||||||
boolean hasI = false;
|
boolean hasI = false;
|
||||||
for (final Product p : products) {
|
for (final Product p : options.products) {
|
||||||
if (p == Product.HIGH_SPEED_TRAIN || p == Product.REGIONAL_TRAIN) {
|
if (p == Product.HIGH_SPEED_TRAIN || p == Product.REGIONAL_TRAIN) {
|
||||||
url.addEncodedQueryParameter("inclMOT_0", "on");
|
url.addEncodedQueryParameter("inclMOT_0", "on");
|
||||||
if (p == Product.HIGH_SPEED_TRAIN)
|
if (p == Product.HIGH_SPEED_TRAIN)
|
||||||
|
@ -2056,7 +2057,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
url.addEncodedQueryParameter("trITMOTvalue100", "10"); // maximum time to walk to first or from last
|
url.addEncodedQueryParameter("trITMOTvalue100", "10"); // maximum time to walk to first or from last
|
||||||
// stop
|
// stop
|
||||||
|
|
||||||
if (options != null && options.contains(Option.BIKE))
|
if (options.options != null && options.options.contains(Option.BIKE))
|
||||||
url.addEncodedQueryParameter("bikeTakeAlong", "1");
|
url.addEncodedQueryParameter("bikeTakeAlong", "1");
|
||||||
|
|
||||||
url.addEncodedQueryParameter("locationServerActive", "1");
|
url.addEncodedQueryParameter("locationServerActive", "1");
|
||||||
|
@ -2080,12 +2081,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
final HttpUrl.Builder url = tripEndpoint.newBuilder();
|
final HttpUrl.Builder url = tripEndpoint.newBuilder();
|
||||||
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
|
appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
|
||||||
options);
|
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = new HttpClient.Callback() {
|
||||||
|
@ -2111,12 +2109,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected QueryTripsResult queryTripsMobile(final Location from, final @Nullable Location via, final Location to,
|
protected QueryTripsResult queryTripsMobile(final Location from, final @Nullable Location via, final Location to,
|
||||||
final Date date, final boolean dep, final @Nullable Collection<Product> products,
|
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
final HttpUrl.Builder url = tripEndpoint.newBuilder();
|
final HttpUrl.Builder url = tripEndpoint.newBuilder();
|
||||||
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
|
appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
|
||||||
options);
|
|
||||||
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
|
||||||
|
|
||||||
final HttpClient.Callback callback = new HttpClient.Callback() {
|
final HttpClient.Callback callback = new HttpClient.Callback() {
|
||||||
|
|
|
@ -67,6 +67,7 @@ import de.schildbach.pte.dto.Stop;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.ParserException;
|
import de.schildbach.pte.exception.ParserException;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
|
@ -148,10 +149,9 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
return jsonTripSearch(from, via, to, date, dep, options != null ? options.products : null,
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
options != null ? options.walkSpeed : null, null);
|
||||||
return jsonTripSearch(from, via, to, date, dep, products, walkSpeed, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -75,6 +75,7 @@ import de.schildbach.pte.dto.Stop;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.ParserException;
|
import de.schildbach.pte.exception.ParserException;
|
||||||
import de.schildbach.pte.exception.SessionExpiredException;
|
import de.schildbach.pte.exception.SessionExpiredException;
|
||||||
import de.schildbach.pte.util.HttpClient;
|
import de.schildbach.pte.util.HttpClient;
|
||||||
|
@ -685,10 +686,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
return queryTripsBinary(from, via, to, date, dep, options);
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
return queryTripsBinary(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -697,8 +696,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final QueryTripsResult queryTripsXml(Location from, @Nullable Location via, Location to, final Date date,
|
protected final QueryTripsResult queryTripsXml(Location from, @Nullable Location via, Location to, final Date date,
|
||||||
final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed,
|
final boolean dep, @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||||
|
|
||||||
if (!from.isIdentified()) {
|
if (!from.isIdentified()) {
|
||||||
|
@ -731,13 +729,16 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
final Calendar c = new GregorianCalendar(timeZone);
|
final Calendar c = new GregorianCalendar(timeZone);
|
||||||
c.setTime(date);
|
c.setTime(date);
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
final CharSequence productsStr;
|
final CharSequence productsStr;
|
||||||
if (products != null)
|
if (options.products != null)
|
||||||
productsStr = productsString(products);
|
productsStr = productsString(options.products);
|
||||||
else
|
else
|
||||||
productsStr = allProductsString();
|
productsStr = allProductsString();
|
||||||
|
|
||||||
final char bikeChar = (options != null && options.contains(Option.BIKE)) ? '1' : '0';
|
final char bikeChar = (options.options != null && options.options.contains(Option.BIKE)) ? '1' : '0';
|
||||||
|
|
||||||
final StringBuilder conReq = new StringBuilder("<ConReq deliverPolyline=\"1\">");
|
final StringBuilder conReq = new StringBuilder("<ConReq deliverPolyline=\"1\">");
|
||||||
conReq.append("<Start>").append(locationXml(from));
|
conReq.append("<Start>").append(locationXml(from));
|
||||||
|
@ -764,7 +765,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
// number of trips forwards
|
// number of trips forwards
|
||||||
conReq.append(" f=\"").append(numTripsRequested).append("\"");
|
conReq.append(" f=\"").append(numTripsRequested).append("\"");
|
||||||
// percentual extension of change time
|
// percentual extension of change time
|
||||||
conReq.append(" chExtension=\"").append(walkSpeed == WalkSpeed.SLOW ? 50 : 0).append("\"");
|
conReq.append(" chExtension=\"").append(options.walkSpeed == WalkSpeed.SLOW ? 50 : 0).append("\"");
|
||||||
// TODO nrChanges: max number of changes
|
// TODO nrChanges: max number of changes
|
||||||
conReq.append(" sMode=\"N\"/>");
|
conReq.append(" sMode=\"N\"/>");
|
||||||
conReq.append("</ConReq>");
|
conReq.append("</ConReq>");
|
||||||
|
@ -1354,9 +1355,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
private final static int QUERY_TRIPS_BINARY_BUFFER_SIZE = 384 * 1024;
|
private final static int QUERY_TRIPS_BINARY_BUFFER_SIZE = 384 * 1024;
|
||||||
|
|
||||||
protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Location via, Location to,
|
protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Location via, Location to,
|
||||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
final Date date, final boolean dep, @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
|
||||||
final @Nullable Set<Option> options) throws IOException {
|
|
||||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||||
|
|
||||||
if (!from.isIdentified()) {
|
if (!from.isIdentified()) {
|
||||||
|
@ -1386,8 +1385,12 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
|
||||||
to = locations.get(0);
|
to = locations.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage);
|
final HttpUrl.Builder url = queryEndpoint.newBuilder().addPathSegment(apiLanguage);
|
||||||
appendQueryTripsBinaryParameters(url, from, via, to, date, dep, products, accessibility, options);
|
appendQueryTripsBinaryParameters(url, from, via, to, date, dep, options.products, options.accessibility,
|
||||||
|
options.options);
|
||||||
return queryTripsBinary(url.build(), from, via, to, QUERY_TRIPS_BINARY_BUFFER_SIZE);
|
return queryTripsBinary(url.build(), from, via, to, QUERY_TRIPS_BINARY_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2014-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -62,6 +62,7 @@ import de.schildbach.pte.dto.Trip;
|
||||||
import de.schildbach.pte.dto.Trip.Individual;
|
import de.schildbach.pte.dto.Trip.Individual;
|
||||||
import de.schildbach.pte.dto.Trip.Leg;
|
import de.schildbach.pte.dto.Trip.Leg;
|
||||||
import de.schildbach.pte.dto.Trip.Public;
|
import de.schildbach.pte.dto.Trip.Public;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.NotFoundException;
|
import de.schildbach.pte.exception.NotFoundException;
|
||||||
import de.schildbach.pte.exception.ParserException;
|
import de.schildbach.pte.exception.ParserException;
|
||||||
|
|
||||||
|
@ -884,9 +885,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null);
|
final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -899,10 +898,13 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
url.addQueryParameter("min_nb_journeys", Integer.toString(this.numTripsRequested));
|
url.addQueryParameter("min_nb_journeys", Integer.toString(this.numTripsRequested));
|
||||||
url.addQueryParameter("depth", "0");
|
url.addQueryParameter("depth", "0");
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
// Set walking speed.
|
// Set walking speed.
|
||||||
if (walkSpeed != null) {
|
if (options.walkSpeed != null) {
|
||||||
final double walkingSpeed;
|
final double walkingSpeed;
|
||||||
switch (walkSpeed) {
|
switch (options.walkSpeed) {
|
||||||
case SLOW:
|
case SLOW:
|
||||||
walkingSpeed = 1.12 * 0.8;
|
walkingSpeed = 1.12 * 0.8;
|
||||||
break;
|
break;
|
||||||
|
@ -918,43 +920,43 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
url.addQueryParameter("walking_speed", Double.toString(walkingSpeed));
|
url.addQueryParameter("walking_speed", Double.toString(walkingSpeed));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options != null && options.contains(Option.BIKE)) {
|
if (options.options != null && options.options.contains(Option.BIKE)) {
|
||||||
url.addQueryParameter("first_section_mode", "bike");
|
url.addQueryParameter("first_section_mode", "bike");
|
||||||
url.addQueryParameter("last_section_mode", "bike");
|
url.addQueryParameter("last_section_mode", "bike");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set forbidden physical modes.
|
// Set forbidden physical modes.
|
||||||
if (products != null && !products.equals(Product.ALL)) {
|
if (options.products != null && !options.products.equals(Product.ALL)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Air");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Air");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Boat");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Boat");
|
||||||
if (!products.contains(Product.REGIONAL_TRAIN)) {
|
if (!options.products.contains(Product.REGIONAL_TRAIN)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Localdistancetrain");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Localdistancetrain");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Train");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Train");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.SUBURBAN_TRAIN)) {
|
if (!options.products.contains(Product.SUBURBAN_TRAIN)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Localtrain");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Localtrain");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Train");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Train");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Rapidtransit");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Rapidtransit");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.SUBWAY)) {
|
if (!options.products.contains(Product.SUBWAY)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Metro");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Metro");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.TRAM)) {
|
if (!options.products.contains(Product.TRAM)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Tramway");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Tramway");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.BUS)) {
|
if (!options.products.contains(Product.BUS)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Bus");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Bus");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Busrapidtransit");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Busrapidtransit");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Coach");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Coach");
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Shuttle");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Shuttle");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.FERRY)) {
|
if (!options.products.contains(Product.FERRY)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Ferry");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Ferry");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.CABLECAR)) {
|
if (!options.products.contains(Product.CABLECAR)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Funicular");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Funicular");
|
||||||
}
|
}
|
||||||
if (!products.contains(Product.ON_DEMAND)) {
|
if (!options.products.contains(Product.ON_DEMAND)) {
|
||||||
url.addQueryParameter("forbidden_uris[]", "physical_mode:Taxi");
|
url.addQueryParameter("forbidden_uris[]", "physical_mode:Taxi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,8 +1024,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTo != null && newFrom != null)
|
if (newTo != null && newFrom != null)
|
||||||
return queryTrips(newFrom, via, newTo, date, dep, products, optimize, walkSpeed, accessibility,
|
return queryTrips(newFrom, via, newTo, date, dep, options);
|
||||||
options);
|
|
||||||
|
|
||||||
if (ambiguousFrom != null || ambiguousTo != null)
|
if (ambiguousFrom != null || ambiguousTo != null)
|
||||||
return new QueryTripsResult(resultHeader, ambiguousFrom, null, ambiguousTo);
|
return new QueryTripsResult(resultHeader, ambiguousFrom, null, ambiguousTo);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,6 +20,7 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -32,10 +33,13 @@ import javax.annotation.Nullable;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Point;
|
import de.schildbach.pte.dto.Point;
|
||||||
import de.schildbach.pte.dto.Position;
|
import de.schildbach.pte.dto.Position;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.util.HttpClient;
|
import de.schildbach.pte.util.HttpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +77,15 @@ public abstract class AbstractNetworkProvider implements NetworkProvider {
|
||||||
|
|
||||||
protected abstract boolean hasCapability(Capability capability);
|
protected abstract boolean hasCapability(Capability capability);
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
||||||
|
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
||||||
|
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException {
|
||||||
|
return queryTrips(from, via, to, date, dep,
|
||||||
|
new TripOptions(products, optimize, walkSpeed, accessibility, options));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Product> defaultProducts() {
|
public Set<Product> defaultProducts() {
|
||||||
return ALL_EXCEPT_HIGHSPEED;
|
return ALL_EXCEPT_HIGHSPEED;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,11 +17,9 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -29,6 +27,7 @@ import de.schildbach.pte.dto.Line;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -48,11 +47,8 @@ public class AvvProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
|
||||||
accessibility, options);
|
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
|
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
|
||||||
url.addEncodedQueryParameter("inclMOT_13", "on");
|
url.addEncodedQueryParameter("inclMOT_13", "on");
|
||||||
url.addEncodedQueryParameter("inclMOT_14", "on");
|
url.addEncodedQueryParameter("inclMOT_14", "on");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,10 +20,8 @@ package de.schildbach.pte;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -39,6 +37,7 @@ import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -138,13 +137,10 @@ public class BayernProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
if (options != null && options.products != null) {
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
for (final Product p : options.products) {
|
||||||
accessibility, options);
|
|
||||||
if (products != null) {
|
|
||||||
for (final Product p : products) {
|
|
||||||
if (p == Product.HIGH_SPEED_TRAIN)
|
if (p == Product.HIGH_SPEED_TRAIN)
|
||||||
url.addEncodedQueryParameter("inclMOT_15", "on").addEncodedQueryParameter("inclMOT_16", "on");
|
url.addEncodedQueryParameter("inclMOT_15", "on").addEncodedQueryParameter("inclMOT_16", "on");
|
||||||
if (p == Product.REGIONAL_TRAIN)
|
if (p == Product.REGIONAL_TRAIN)
|
||||||
|
@ -158,10 +154,8 @@ public class BayernProvider extends AbstractEfaProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
return queryTripsMobile(from, via, to, date, dep, options);
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,19 +17,17 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -51,11 +49,8 @@ public class BsvagProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
|
||||||
accessibility, options);
|
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on");
|
url.addEncodedQueryParameter("inclMOT_11", "on");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,7 +19,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -30,6 +29,7 @@ import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -50,10 +50,8 @@ public class EireannProvider extends AbstractHafasLegacyProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
return queryTripsXml(from, via, to, date, dep, options);
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
return queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -58,6 +58,7 @@ import de.schildbach.pte.dto.Style;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.ParserException;
|
import de.schildbach.pte.exception.ParserException;
|
||||||
import de.schildbach.pte.util.HttpClient;
|
import de.schildbach.pte.util.HttpClient;
|
||||||
import de.schildbach.pte.util.XmlPullUtil;
|
import de.schildbach.pte.util.XmlPullUtil;
|
||||||
|
@ -435,8 +436,7 @@ public class HslProvider extends AbstractNetworkProvider {
|
||||||
// NOTE: HSL ignores accessibility
|
// NOTE: HSL ignores accessibility
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
||||||
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
@Nullable TripOptions options) throws IOException {
|
||||||
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException {
|
|
||||||
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
|
||||||
|
|
||||||
if (!from.isIdentified()) {
|
if (!from.isIdentified()) {
|
||||||
|
@ -475,22 +475,25 @@ public class HslProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
url.addQueryParameter("timetype", dep ? "departure" : "arrival");
|
url.addQueryParameter("timetype", dep ? "departure" : "arrival");
|
||||||
|
|
||||||
if (walkSpeed != WalkSpeed.NORMAL)
|
if (options == null)
|
||||||
url.addQueryParameter("walk_speed", Integer.toString(walkSpeed == WalkSpeed.SLOW ? 30 : 100));
|
options = new TripOptions();
|
||||||
|
|
||||||
|
if (options.walkSpeed != WalkSpeed.NORMAL)
|
||||||
|
url.addQueryParameter("walk_speed", Integer.toString(options.walkSpeed == WalkSpeed.SLOW ? 30 : 100));
|
||||||
url.addQueryParameter("show", "5");
|
url.addQueryParameter("show", "5");
|
||||||
|
|
||||||
if (products != null && products.size() > 0) {
|
if (options.products != null && options.products.size() > 0) {
|
||||||
List<String> tt = new ArrayList<>();
|
List<String> tt = new ArrayList<>();
|
||||||
if (products.contains(Product.HIGH_SPEED_TRAIN) || products.contains(Product.REGIONAL_TRAIN)
|
if (options.products.contains(Product.HIGH_SPEED_TRAIN) || options.products.contains(Product.REGIONAL_TRAIN)
|
||||||
|| products.contains(Product.SUBURBAN_TRAIN))
|
|| options.products.contains(Product.SUBURBAN_TRAIN))
|
||||||
tt.add("train");
|
tt.add("train");
|
||||||
if (products.contains(Product.SUBWAY))
|
if (options.products.contains(Product.SUBWAY))
|
||||||
tt.add("metro");
|
tt.add("metro");
|
||||||
if (products.contains(Product.TRAM))
|
if (options.products.contains(Product.TRAM))
|
||||||
tt.add("tram");
|
tt.add("tram");
|
||||||
if (products.contains(Product.BUS))
|
if (options.products.contains(Product.BUS))
|
||||||
tt.add("bus");
|
tt.add("bus");
|
||||||
if (products.contains(Product.FERRY))
|
if (options.products.contains(Product.FERRY))
|
||||||
tt.add("ferry");
|
tt.add("ferry");
|
||||||
|
|
||||||
if (tt.size() > 0)
|
if (tt.size() > 0)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -60,6 +60,7 @@ import de.schildbach.pte.dto.Stop;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
import de.schildbach.pte.exception.InternalErrorException;
|
import de.schildbach.pte.exception.InternalErrorException;
|
||||||
import de.schildbach.pte.exception.NotFoundException;
|
import de.schildbach.pte.exception.NotFoundException;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
@ -862,8 +863,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
public QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
||||||
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
@Nullable TripOptions options) throws IOException {
|
||||||
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException {
|
|
||||||
if (!(from.hasId() || from.hasLocation()))
|
if (!(from.hasId() || from.hasLocation()))
|
||||||
return ambiguousQueryTrips(from, via, to);
|
return ambiguousQueryTrips(from, via, to);
|
||||||
|
|
||||||
|
@ -886,13 +886,17 @@ public class NegentweeProvider extends AbstractNetworkProvider {
|
||||||
queryParameters.add(new QueryParameter("via", locationToQueryParameterString(via)));
|
queryParameters.add(new QueryParameter("via", locationToQueryParameterString(via)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walkSpeed != null && walkSpeed == WalkSpeed.SLOW) {
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
|
if (options.walkSpeed != null && options.walkSpeed == WalkSpeed.SLOW) {
|
||||||
queryParameters.add(new QueryParameter("interchangeTime", InterchangeTime.EXTRA.toString()));
|
queryParameters.add(new QueryParameter("interchangeTime", InterchangeTime.EXTRA.toString()));
|
||||||
} else {
|
} else {
|
||||||
queryParameters.add(new QueryParameter("interchangeTime", InterchangeTime.STANDARD.toString()));
|
queryParameters.add(new QueryParameter("interchangeTime", InterchangeTime.STANDARD.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add trip product options to query
|
// Add trip product options to query
|
||||||
|
Set<Product> products = options.products;
|
||||||
if (products == null || products.size() == 0) {
|
if (products == null || products.size() == 0) {
|
||||||
products = defaultProducts();
|
products = defaultProducts();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -34,6 +34,7 @@ import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to be implemented by providers of transportation networks.
|
* Interface to be implemented by providers of transportation networks.
|
||||||
|
@ -137,20 +138,17 @@ public interface NetworkProvider {
|
||||||
* desired date for departing, mandatory
|
* desired date for departing, mandatory
|
||||||
* @param dep
|
* @param dep
|
||||||
* date is departure date? {@code true} for departure, {@code false} for arrival
|
* date is departure date? {@code true} for departure, {@code false} for arrival
|
||||||
* @param products
|
|
||||||
* products to take into account, or {@code null} for the provider default
|
|
||||||
* @param optimize
|
|
||||||
* optimize trip for one aspect, e.g. duration
|
|
||||||
* @param walkSpeed
|
|
||||||
* walking ability, or {@code null} for the provider default
|
|
||||||
* @param accessibility
|
|
||||||
* route accessibility, or {@code null} for the provider default
|
|
||||||
* @param options
|
* @param options
|
||||||
* additional options, or {@code null} for the provider default
|
* additional trip options such as products, optimize, walkSpeed and accessibility, or
|
||||||
|
* {@code null} for the provider default
|
||||||
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible
|
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible
|
||||||
* trips
|
* trips
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
||||||
|
@Nullable TripOptions options) throws IOException;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
QueryTripsResult queryTrips(Location from, @Nullable Location via, Location to, Date date, boolean dep,
|
||||||
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
||||||
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;
|
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -31,11 +30,11 @@ import com.google.common.base.Strings;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyLocationsResult;
|
import de.schildbach.pte.dto.NearbyLocationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -78,10 +77,8 @@ public class StvProvider extends AbstractEfaProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
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 Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
|
return queryTripsMobile(from, via, to, date, dep, options);
|
||||||
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
|
|
||||||
return queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,11 +17,9 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -29,6 +27,7 @@ import de.schildbach.pte.dto.Line;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -51,13 +50,10 @@ public class SydneyProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
if (options != null && options.products != null) {
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
for (final Product p : options.products) {
|
||||||
accessibility, options);
|
|
||||||
if (products != null) {
|
|
||||||
for (final Product p : products) {
|
|
||||||
if (p == Product.BUS)
|
if (p == Product.BUS)
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on"); // school bus
|
url.addEncodedQueryParameter("inclMOT_11", "on"); // school bus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,9 +18,7 @@
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -29,6 +27,7 @@ import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -72,11 +71,8 @@ public class VgnProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
final @Nullable Location via, final Location to, final Date date, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed,
|
|
||||||
accessibility, options);
|
|
||||||
url.addEncodedQueryParameter("itdLPxx_showTariffLevel", "1");
|
url.addEncodedQueryParameter("itdLPxx_showTariffLevel", "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,15 +17,14 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Line;
|
import de.schildbach.pte.dto.Line;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -44,11 +43,8 @@ public class VmsProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
|
||||||
accessibility, options);
|
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on");
|
url.addEncodedQueryParameter("inclMOT_11", "on");
|
||||||
url.addEncodedQueryParameter("inclMOT_13", "on");
|
url.addEncodedQueryParameter("inclMOT_13", "on");
|
||||||
url.addEncodedQueryParameter("inclMOT_14", "on");
|
url.addEncodedQueryParameter("inclMOT_14", "on");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,14 +17,12 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -45,11 +43,8 @@ public class VmvProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
|
||||||
accessibility, options);
|
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on");
|
url.addEncodedQueryParameter("inclMOT_11", "on");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,11 +17,9 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -32,6 +30,7 @@ import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
import de.schildbach.pte.dto.Style.Shape;
|
import de.schildbach.pte.dto.Style.Shape;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -61,13 +60,10 @@ public class VrrProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
if (options != null && options.products != null) {
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
for (final Product p : options.products) {
|
||||||
accessibility, options);
|
|
||||||
if (products != null) {
|
|
||||||
for (final Product p : products) {
|
|
||||||
if (p == Product.CABLECAR)
|
if (p == Product.CABLECAR)
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on"); // Schwebebahn
|
url.addEncodedQueryParameter("inclMOT_11", "on"); // Schwebebahn
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -72,6 +72,7 @@ import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
import de.schildbach.pte.dto.SuggestedLocation;
|
import de.schildbach.pte.dto.SuggestedLocation;
|
||||||
import de.schildbach.pte.dto.Trip;
|
import de.schildbach.pte.dto.Trip;
|
||||||
import de.schildbach.pte.dto.Trip.Leg;
|
import de.schildbach.pte.dto.Trip.Leg;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -655,9 +656,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
// options not supported.
|
// options not supported.
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, Date date,
|
public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, Date date,
|
||||||
boolean dep, final @Nullable Set<Product> products, final @Nullable Optimize optimize,
|
boolean dep, @Nullable TripOptions options) throws IOException {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
|
||||||
@Nullable Set<Option> options) throws IOException {
|
|
||||||
// The EXACT_POINTS feature generates an about 50% bigger API response, probably well compressible.
|
// The EXACT_POINTS feature generates an about 50% bigger API response, probably well compressible.
|
||||||
final boolean EXACT_POINTS = true;
|
final boolean EXACT_POINTS = true;
|
||||||
final List<Location> ambiguousFrom = new ArrayList<>();
|
final List<Location> ambiguousFrom = new ArrayList<>();
|
||||||
|
@ -688,6 +687,9 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
QueryTripsResult.Status.UNKNOWN_TO);
|
QueryTripsResult.Status.UNKNOWN_TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options == null)
|
||||||
|
options = new TripOptions();
|
||||||
|
|
||||||
final HttpUrl.Builder url = API_BASE.newBuilder();
|
final HttpUrl.Builder url = API_BASE.newBuilder();
|
||||||
url.addQueryParameter("eID", "tx_vrsinfo_ass2_router");
|
url.addQueryParameter("eID", "tx_vrsinfo_ass2_router");
|
||||||
url.addQueryParameter("f", fromString);
|
url.addQueryParameter("f", fromString);
|
||||||
|
@ -697,8 +699,8 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
}
|
}
|
||||||
url.addQueryParameter(dep ? "d" : "a", formatDate(date));
|
url.addQueryParameter(dep ? "d" : "a", formatDate(date));
|
||||||
url.addQueryParameter("s", "t");
|
url.addQueryParameter("s", "t");
|
||||||
if (products != null && !products.equals(Product.ALL))
|
if (options.products != null && !options.products.equals(Product.ALL))
|
||||||
url.addQueryParameter("p", generateProducts(products));
|
url.addQueryParameter("p", generateProducts(options.products));
|
||||||
url.addQueryParameter("o", "v" + (EXACT_POINTS ? "p" : ""));
|
url.addQueryParameter("o", "v" + (EXACT_POINTS ? "p" : ""));
|
||||||
|
|
||||||
final CharSequence page = httpClient.get(url.build());
|
final CharSequence page = httpClient.get(url.build());
|
||||||
|
@ -895,7 +897,7 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
context.from = from;
|
context.from = from;
|
||||||
context.to = to;
|
context.to = to;
|
||||||
context.via = via;
|
context.via = via;
|
||||||
context.products = products;
|
context.products = options.products;
|
||||||
if (trips.size() == 1) {
|
if (trips.size() == 1) {
|
||||||
if (dep)
|
if (dep)
|
||||||
context.disableLater();
|
context.disableLater();
|
||||||
|
@ -948,12 +950,11 @@ public class VrsProvider extends AbstractNetworkProvider {
|
||||||
@Override
|
@Override
|
||||||
public QueryTripsResult queryMoreTrips(QueryTripsContext context, boolean later) throws IOException {
|
public QueryTripsResult queryMoreTrips(QueryTripsContext context, boolean later) throws IOException {
|
||||||
Context ctx = (Context) context;
|
Context ctx = (Context) context;
|
||||||
|
TripOptions options = new TripOptions(ctx.products, null, null, null, null);
|
||||||
if (later) {
|
if (later) {
|
||||||
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getLastDeparture(), true, ctx.products, null, null, null,
|
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getLastDeparture(), true, options);
|
||||||
null);
|
|
||||||
} else {
|
} else {
|
||||||
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getFirstArrival(), false, ctx.products, null, null, null,
|
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getFirstArrival(), false, options);
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2013-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -17,11 +17,9 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -30,6 +28,7 @@ import com.google.common.base.Charsets;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
@ -50,13 +49,10 @@ public class WienProvider extends AbstractEfaProvider {
|
||||||
@Override
|
@Override
|
||||||
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
protected void appendXsltTripRequestParameters(final HttpUrl.Builder url, final Location from,
|
||||||
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
final @Nullable Location via, final Location to, final Date time, final boolean dep,
|
||||||
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
|
final @Nullable TripOptions options) {
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
|
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
|
||||||
final @Nullable Set<Option> options) {
|
if (options != null && options.products != null) {
|
||||||
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
|
for (final Product p : options.products) {
|
||||||
accessibility, options);
|
|
||||||
if (products != null) {
|
|
||||||
for (final Product p : products) {
|
|
||||||
if (p == Product.BUS)
|
if (p == Product.BUS)
|
||||||
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
|
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
|
||||||
}
|
}
|
||||||
|
|
84
enabler/src/de/schildbach/pte/dto/TripOptions.java
Normal file
84
enabler/src/de/schildbach/pte/dto/TripOptions.java
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.schildbach.pte.dto;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.MoreObjects.ToStringHelper;
|
||||||
|
|
||||||
|
import de.schildbach.pte.NetworkProvider;
|
||||||
|
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||||
|
import de.schildbach.pte.NetworkProvider.Optimize;
|
||||||
|
import de.schildbach.pte.NetworkProvider.Option;
|
||||||
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for {@link NetworkProvider#queryTrips()}.
|
||||||
|
*
|
||||||
|
* @author Ialokim
|
||||||
|
*/
|
||||||
|
public class TripOptions {
|
||||||
|
public final @Nullable Set<Product> products;
|
||||||
|
public final @Nullable Optimize optimize;
|
||||||
|
public final @Nullable WalkSpeed walkSpeed;
|
||||||
|
public final @Nullable Accessibility accessibility;
|
||||||
|
public final @Nullable Set<Option> options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param products
|
||||||
|
* products to take into account, or {@code null} for the provider default
|
||||||
|
* @param optimize
|
||||||
|
* optimize trip for one aspect, e.g. duration
|
||||||
|
* @param walkSpeed
|
||||||
|
* walking ability, or {@code null} for the provider default
|
||||||
|
* @param accessibility
|
||||||
|
* route accessibility, or {@code null} for the provider default
|
||||||
|
* @param options
|
||||||
|
* additional options, or {@code null} for the provider default
|
||||||
|
*/
|
||||||
|
public TripOptions(@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
|
||||||
|
@Nullable Accessibility accessibility, @Nullable Set<Option> options) {
|
||||||
|
this.products = products;
|
||||||
|
this.optimize = optimize;
|
||||||
|
this.walkSpeed = walkSpeed;
|
||||||
|
this.accessibility = accessibility;
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TripOptions() {
|
||||||
|
this.products = null;
|
||||||
|
this.optimize = null;
|
||||||
|
this.walkSpeed = null;
|
||||||
|
this.accessibility = null;
|
||||||
|
this.options = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final ToStringHelper helper = MoreObjects.toStringHelper(this);
|
||||||
|
helper.add("products", products);
|
||||||
|
helper.addValue(optimize);
|
||||||
|
helper.addValue(walkSpeed);
|
||||||
|
helper.addValue(accessibility);
|
||||||
|
helper.add("options", options);
|
||||||
|
return helper.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,6 +39,7 @@ import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||||
|
import de.schildbach.pte.dto.TripOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -123,7 +124,8 @@ public abstract class AbstractProviderLiveTest {
|
||||||
protected final QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
protected final QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to,
|
||||||
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
final Date date, final boolean dep, final @Nullable Set<Product> products,
|
||||||
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility) throws IOException {
|
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility) throws IOException {
|
||||||
return provider.queryTrips(from, via, to, date, dep, products, null, walkSpeed, accessibility, null);
|
return provider.queryTrips(from, via, to, date, dep,
|
||||||
|
new TripOptions(products, null, walkSpeed, accessibility, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later)
|
protected final QueryTripsResult queryMoreTrips(final QueryTripsContext context, final boolean later)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright the original author or authors.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
@ -26,12 +26,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
|
||||||
import de.schildbach.pte.RtProvider;
|
import de.schildbach.pte.RtProvider;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.Product;
|
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +49,6 @@ public class TripController {
|
||||||
@RequestParam(value = "toId", required = false) final String toId) throws IOException {
|
@RequestParam(value = "toId", required = false) final String toId) throws IOException {
|
||||||
final Location fromLocation = new Location(fromType, fromId, null, from);
|
final Location fromLocation = new Location(fromType, fromId, null, from);
|
||||||
final Location toLocation = new Location(toType, toId, null, to);
|
final Location toLocation = new Location(toType, toId, null, to);
|
||||||
return provider.queryTrips(fromLocation, null, toLocation, new Date(), true, Product.ALL, null,
|
return provider.queryTrips(fromLocation, null, toLocation, new Date(), true, null);
|
||||||
WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue