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:
Ialokim 2018-08-01 13:22:15 +02:00 committed by Andreas Schildbach
parent af94ee8724
commit 79ff93b80f
23 changed files with 263 additions and 208 deletions

View file

@ -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
* 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.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Currency;
import java.util.Date;
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.Trip;
import de.schildbach.pte.dto.Trip.Leg;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.exception.InvalidDataException;
import de.schildbach.pte.exception.ParserException;
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,
final @Nullable Location via, final Location to, final Date time, final boolean dep,
final @Nullable Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
@Nullable TripOptions options) {
appendCommonRequestParams(url, "XML");
url.addEncodedQueryParameter("sessionID", "0");
@ -1994,29 +1992,32 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
url.addEncodedQueryParameter("ptOptionsActive", "1"); // enable public 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");
else if (optimize == Optimize.LEAST_CHANGES)
else if (options.optimize == Optimize.LEAST_CHANGES)
url.addEncodedQueryParameter("routeType", "LEASTINTERCHANGE");
else if (optimize == Optimize.LEAST_WALKING)
else if (options.optimize == Optimize.LEAST_WALKING)
url.addEncodedQueryParameter("routeType", "LEASTWALKING");
else if (optimize != null)
log.info("Cannot handle " + optimize + ", ignoring.");
else if (options.optimize != null)
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")
.addEncodedQueryParameter("noSolidStairs", "on");
else if (accessibility == Accessibility.LIMITED)
else if (options.accessibility == Accessibility.LIMITED)
url.addEncodedQueryParameter("imparedOptionsActive", "1").addEncodedQueryParameter("wheelchair", "on")
.addEncodedQueryParameter("lowPlatformVhcl", "on").addEncodedQueryParameter("noSolidStairs", "on");
if (products != null) {
if (options.products != null) {
url.addEncodedQueryParameter("includedMeans", "checkbox");
boolean hasI = false;
for (final Product p : products) {
for (final Product p : options.products) {
if (p == Product.HIGH_SPEED_TRAIN || p == Product.REGIONAL_TRAIN) {
url.addEncodedQueryParameter("inclMOT_0", "on");
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
// stop
if (options != null && options.contains(Option.BIKE))
if (options.options != null && options.options.contains(Option.BIKE))
url.addEncodedQueryParameter("bikeTakeAlong", "1");
url.addEncodedQueryParameter("locationServerActive", "1");
@ -2080,12 +2081,9 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
@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 {
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
final HttpUrl.Builder url = tripEndpoint.newBuilder();
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
options);
appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
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,
final Date date, final boolean dep, final @Nullable Collection<Product> products,
final @Nullable Optimize optimize, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
final HttpUrl.Builder url = tripEndpoint.newBuilder();
appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed, accessibility,
options);
appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
final AtomicReference<QueryTripsResult> result = new AtomicReference<>();
final HttpClient.Callback callback = new HttpClient.Callback() {

View file

@ -67,6 +67,7 @@ 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.dto.TripOptions;
import de.schildbach.pte.exception.ParserException;
import de.schildbach.pte.util.ParserUtils;
@ -148,10 +149,9 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
@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, walkSpeed, null);
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return jsonTripSearch(from, via, to, date, dep, options != null ? options.products : null,
options != null ? options.walkSpeed : null, null);
}
@Override

View file

@ -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
* 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.SuggestedLocation;
import de.schildbach.pte.dto.Trip;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.exception.ParserException;
import de.schildbach.pte.exception.SessionExpiredException;
import de.schildbach.pte.util.HttpClient;
@ -685,10 +686,8 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
@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 queryTripsBinary(from, via, to, date, dep, products, walkSpeed, accessibility, options);
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return queryTripsBinary(from, via, to, date, dep, options);
}
@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,
final boolean dep, final @Nullable Set<Product> products, final @Nullable WalkSpeed walkSpeed,
final @Nullable Accessibility accessibility, final @Nullable Set<Option> options) throws IOException {
final boolean dep, @Nullable TripOptions options) throws IOException {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
if (!from.isIdentified()) {
@ -731,13 +729,16 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
final Calendar c = new GregorianCalendar(timeZone);
c.setTime(date);
if (options == null)
options = new TripOptions();
final CharSequence productsStr;
if (products != null)
productsStr = productsString(products);
if (options.products != null)
productsStr = productsString(options.products);
else
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\">");
conReq.append("<Start>").append(locationXml(from));
@ -764,7 +765,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
// number of trips forwards
conReq.append(" f=\"").append(numTripsRequested).append("\"");
// 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
conReq.append(" sMode=\"N\"/>");
conReq.append("</ConReq>");
@ -1354,9 +1355,7 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
private final static int QUERY_TRIPS_BINARY_BUFFER_SIZE = 384 * 1024;
protected final QueryTripsResult queryTripsBinary(Location from, @Nullable Location via, Location to,
final Date date, final boolean dep, final @Nullable Set<Product> products,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) throws IOException {
final Date date, final boolean dep, @Nullable TripOptions options) throws IOException {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
if (!from.isIdentified()) {
@ -1386,8 +1385,12 @@ public abstract class AbstractHafasLegacyProvider extends AbstractHafasProvider
to = locations.get(0);
}
if (options == null)
options = new TripOptions();
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);
}

View file

@ -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
* 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.Leg;
import de.schildbach.pte.dto.Trip.Public;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.exception.NotFoundException;
import de.schildbach.pte.exception.ParserException;
@ -884,9 +885,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
@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 {
final Date date, final boolean dep, @Nullable TripOptions options) throws IOException {
final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null);
try {
@ -899,10 +898,13 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
url.addQueryParameter("min_nb_journeys", Integer.toString(this.numTripsRequested));
url.addQueryParameter("depth", "0");
if (options == null)
options = new TripOptions();
// Set walking speed.
if (walkSpeed != null) {
if (options.walkSpeed != null) {
final double walkingSpeed;
switch (walkSpeed) {
switch (options.walkSpeed) {
case SLOW:
walkingSpeed = 1.12 * 0.8;
break;
@ -918,43 +920,43 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
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("last_section_mode", "bike");
}
// 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: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: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:Train");
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");
}
if (!products.contains(Product.TRAM)) {
if (!options.products.contains(Product.TRAM)) {
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:Busrapidtransit");
url.addQueryParameter("forbidden_uris[]", "physical_mode:Coach");
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");
}
if (!products.contains(Product.CABLECAR)) {
if (!options.products.contains(Product.CABLECAR)) {
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");
}
}
@ -1022,8 +1024,7 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider {
}
if (newTo != null && newFrom != null)
return queryTrips(newFrom, via, newTo, date, dep, products, optimize, walkSpeed, accessibility,
options);
return queryTrips(newFrom, via, newTo, date, dep, options);
if (ambiguousFrom != null || ambiguousTo != null)
return new QueryTripsResult(resultHeader, ambiguousFrom, null, ambiguousTo);

View file

@ -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
* 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.net.Proxy;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
@ -32,10 +33,13 @@ import javax.annotation.Nullable;
import com.google.common.base.Charsets;
import com.google.common.base.Strings;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Point;
import de.schildbach.pte.dto.Position;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.util.HttpClient;
/**
@ -73,6 +77,15 @@ public abstract class AbstractNetworkProvider implements NetworkProvider {
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
public Set<Product> defaultProducts() {
return ALL_EXCEPT_HIGHSPEED;

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,11 +17,9 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
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.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -48,11 +47,8 @@ public class AvvProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
url.addEncodedQueryParameter("inclMOT_13", "on");
url.addEncodedQueryParameter("inclMOT_14", "on");

View file

@ -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
* 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 java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.EnumSet;
import java.util.Set;
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.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -138,13 +137,10 @@ public class BayernProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
if (products != null) {
for (final Product p : products) {
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
if (options != null && options.products != null) {
for (final Product p : options.products) {
if (p == Product.HIGH_SPEED_TRAIN)
url.addEncodedQueryParameter("inclMOT_15", "on").addEncodedQueryParameter("inclMOT_16", "on");
if (p == Product.REGIONAL_TRAIN)
@ -158,10 +154,8 @@ public class BayernProvider extends AbstractEfaProvider {
@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 queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return queryTripsMobile(from, via, to, date, dep, options);
}
@Override

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,19 +17,17 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import com.google.common.base.Charsets;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -51,11 +49,8 @@ public class BsvagProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
url.addEncodedQueryParameter("inclMOT_11", "on");
}

View file

@ -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
* 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.util.Date;
import java.util.Set;
import java.util.regex.Matcher;
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.QueryTripsContext;
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -50,10 +50,8 @@ public class EireannProvider extends AbstractHafasLegacyProvider {
@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 queryTripsXml(from, via, to, date, dep, products, walkSpeed, accessibility, options);
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return queryTripsXml(from, via, to, date, dep, options);
}
@Override

View file

@ -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
* 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.SuggestedLocation;
import de.schildbach.pte.dto.Trip;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.exception.ParserException;
import de.schildbach.pte.util.HttpClient;
import de.schildbach.pte.util.XmlPullUtil;
@ -435,8 +436,7 @@ public class HslProvider extends AbstractNetworkProvider {
// NOTE: HSL ignores accessibility
@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 {
@Nullable TripOptions options) throws IOException {
final ResultHeader header = new ResultHeader(network, SERVER_PRODUCT);
if (!from.isIdentified()) {
@ -475,22 +475,25 @@ public class HslProvider extends AbstractNetworkProvider {
url.addQueryParameter("timetype", dep ? "departure" : "arrival");
if (walkSpeed != WalkSpeed.NORMAL)
url.addQueryParameter("walk_speed", Integer.toString(walkSpeed == WalkSpeed.SLOW ? 30 : 100));
if (options == null)
options = new TripOptions();
if (options.walkSpeed != WalkSpeed.NORMAL)
url.addQueryParameter("walk_speed", Integer.toString(options.walkSpeed == WalkSpeed.SLOW ? 30 : 100));
url.addQueryParameter("show", "5");
if (products != null && products.size() > 0) {
if (options.products != null && options.products.size() > 0) {
List<String> tt = new ArrayList<>();
if (products.contains(Product.HIGH_SPEED_TRAIN) || products.contains(Product.REGIONAL_TRAIN)
|| products.contains(Product.SUBURBAN_TRAIN))
if (options.products.contains(Product.HIGH_SPEED_TRAIN) || options.products.contains(Product.REGIONAL_TRAIN)
|| options.products.contains(Product.SUBURBAN_TRAIN))
tt.add("train");
if (products.contains(Product.SUBWAY))
if (options.products.contains(Product.SUBWAY))
tt.add("metro");
if (products.contains(Product.TRAM))
if (options.products.contains(Product.TRAM))
tt.add("tram");
if (products.contains(Product.BUS))
if (options.products.contains(Product.BUS))
tt.add("bus");
if (products.contains(Product.FERRY))
if (options.products.contains(Product.FERRY))
tt.add("ferry");
if (tt.size() > 0)

View file

@ -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
* 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.SuggestedLocation;
import de.schildbach.pte.dto.Trip;
import de.schildbach.pte.dto.TripOptions;
import de.schildbach.pte.exception.InternalErrorException;
import de.schildbach.pte.exception.NotFoundException;
import de.schildbach.pte.util.ParserUtils;
@ -862,8 +863,7 @@ public class NegentweeProvider extends AbstractNetworkProvider {
@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 {
@Nullable TripOptions options) throws IOException {
if (!(from.hasId() || from.hasLocation()))
return ambiguousQueryTrips(from, via, to);
@ -886,13 +886,17 @@ public class NegentweeProvider extends AbstractNetworkProvider {
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()));
} else {
queryParameters.add(new QueryParameter("interchangeTime", InterchangeTime.STANDARD.toString()));
}
// Add trip product options to query
Set<Product> products = options.products;
if (products == null || products.size() == 0) {
products = defaultProducts();
}

View file

@ -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
* 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.Style;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* Interface to be implemented by providers of transportation networks.
@ -137,20 +138,17 @@ public interface NetworkProvider {
* desired date for departing, mandatory
* @param dep
* 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
* 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
* trips
* @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,
@Nullable Set<Product> products, @Nullable Optimize optimize, @Nullable WalkSpeed walkSpeed,
@Nullable Accessibility accessibility, @Nullable Set<Option> options) throws IOException;

View file

@ -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
* 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.util.Date;
import java.util.EnumSet;
import java.util.Set;
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.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 de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -78,10 +77,8 @@ public class StvProvider extends AbstractEfaProvider {
@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 queryTripsMobile(from, via, to, date, dep, products, optimize, walkSpeed, accessibility, options);
final Date date, final boolean dep, final @Nullable TripOptions options) throws IOException {
return queryTripsMobile(from, via, to, date, dep, options);
}
@Override

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,11 +17,9 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
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.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -51,13 +50,10 @@ public class SydneyProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
if (products != null) {
for (final Product p : products) {
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
if (options != null && options.products != null) {
for (final Product p : options.products) {
if (p == Product.BUS)
url.addEncodedQueryParameter("inclMOT_11", "on"); // school bus
}

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -18,9 +18,7 @@
package de.schildbach.pte;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
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.Product;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -72,11 +71,8 @@ public class VgnProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, date, dep, products, optimize, walkSpeed,
accessibility, options);
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, date, dep, options);
url.addEncodedQueryParameter("itdLPxx_showTariffLevel", "1");
}
}

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,15 +17,14 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
import javax.annotation.Nullable;
import de.schildbach.pte.dto.Line;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -44,11 +43,8 @@ public class VmsProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
url.addEncodedQueryParameter("inclMOT_11", "on");
url.addEncodedQueryParameter("inclMOT_13", "on");
url.addEncodedQueryParameter("inclMOT_14", "on");

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,14 +17,12 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
import javax.annotation.Nullable;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -45,11 +43,8 @@ public class VmvProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
url.addEncodedQueryParameter("inclMOT_11", "on");
}
}

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,11 +17,9 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
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.Style;
import de.schildbach.pte.dto.Style.Shape;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -61,13 +60,10 @@ public class VrrProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
if (products != null) {
for (final Product p : products) {
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
if (options != null && options.products != null) {
for (final Product p : options.products) {
if (p == Product.CABLECAR)
url.addEncodedQueryParameter("inclMOT_11", "on"); // Schwebebahn
}

View file

@ -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
* 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.Trip;
import de.schildbach.pte.dto.Trip.Leg;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -655,9 +656,7 @@ public class VrsProvider extends AbstractNetworkProvider {
// options not supported.
@Override
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,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
@Nullable Set<Option> options) throws IOException {
boolean dep, @Nullable TripOptions options) throws IOException {
// The EXACT_POINTS feature generates an about 50% bigger API response, probably well compressible.
final boolean EXACT_POINTS = true;
final List<Location> ambiguousFrom = new ArrayList<>();
@ -688,6 +687,9 @@ public class VrsProvider extends AbstractNetworkProvider {
QueryTripsResult.Status.UNKNOWN_TO);
}
if (options == null)
options = new TripOptions();
final HttpUrl.Builder url = API_BASE.newBuilder();
url.addQueryParameter("eID", "tx_vrsinfo_ass2_router");
url.addQueryParameter("f", fromString);
@ -697,8 +699,8 @@ public class VrsProvider extends AbstractNetworkProvider {
}
url.addQueryParameter(dep ? "d" : "a", formatDate(date));
url.addQueryParameter("s", "t");
if (products != null && !products.equals(Product.ALL))
url.addQueryParameter("p", generateProducts(products));
if (options.products != null && !options.products.equals(Product.ALL))
url.addQueryParameter("p", generateProducts(options.products));
url.addQueryParameter("o", "v" + (EXACT_POINTS ? "p" : ""));
final CharSequence page = httpClient.get(url.build());
@ -895,7 +897,7 @@ public class VrsProvider extends AbstractNetworkProvider {
context.from = from;
context.to = to;
context.via = via;
context.products = products;
context.products = options.products;
if (trips.size() == 1) {
if (dep)
context.disableLater();
@ -948,12 +950,11 @@ public class VrsProvider extends AbstractNetworkProvider {
@Override
public QueryTripsResult queryMoreTrips(QueryTripsContext context, boolean later) throws IOException {
Context ctx = (Context) context;
TripOptions options = new TripOptions(ctx.products, null, null, null, null);
if (later) {
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getLastDeparture(), true, ctx.products, null, null, null,
null);
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getLastDeparture(), true, options);
} else {
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getFirstArrival(), false, ctx.products, null, null, null,
null);
return queryTrips(ctx.from, ctx.via, ctx.to, ctx.getFirstArrival(), false, options);
}
}

View file

@ -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
* it under the terms of the GNU General Public License as published by
@ -17,11 +17,9 @@
package de.schildbach.pte;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
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.Product;
import de.schildbach.pte.dto.Style;
import de.schildbach.pte.dto.TripOptions;
import okhttp3.HttpUrl;
@ -50,13 +49,10 @@ public class WienProvider extends AbstractEfaProvider {
@Override
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 Collection<Product> products, final @Nullable Optimize optimize,
final @Nullable WalkSpeed walkSpeed, final @Nullable Accessibility accessibility,
final @Nullable Set<Option> options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, products, optimize, walkSpeed,
accessibility, options);
if (products != null) {
for (final Product p : products) {
final @Nullable TripOptions options) {
super.appendXsltTripRequestParameters(url, from, via, to, time, dep, options);
if (options != null && options.products != null) {
for (final Product p : options.products) {
if (p == Product.BUS)
url.addEncodedQueryParameter("inclMOT_11", "on"); // night bus
}

View 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();
}
}

View file

@ -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
* 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.QueryTripsResult;
import de.schildbach.pte.dto.SuggestLocationsResult;
import de.schildbach.pte.dto.TripOptions;
/**
* @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,
final Date date, final boolean dep, final @Nullable Set<Product> products,
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)

View file

@ -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
* 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.ResponseBody;
import de.schildbach.pte.NetworkProvider.Accessibility;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.RtProvider;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.Product;
import de.schildbach.pte.dto.QueryTripsResult;
/**
@ -52,7 +49,6 @@ public class TripController {
@RequestParam(value = "toId", required = false) final String toId) throws IOException {
final Location fromLocation = new Location(fromType, fromId, null, from);
final Location toLocation = new Location(toType, toId, null, to);
return provider.queryTrips(fromLocation, null, toLocation, new Date(), true, Product.ALL, null,
WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
return provider.queryTrips(fromLocation, null, toLocation, new Date(), true, null);
}
}