mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 16:29:51 +00:00
Migrate Sweden to binary connections query
This commit is contained in:
parent
f65aa7ea57
commit
efa52d7f3d
2 changed files with 37 additions and 5 deletions
|
@ -90,6 +90,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
private final Charset xmlMlcResEncoding;
|
private final Charset xmlMlcResEncoding;
|
||||||
private boolean dominantPlanStopTime = false;
|
private boolean dominantPlanStopTime = false;
|
||||||
private boolean canDoEquivs = true;
|
private boolean canDoEquivs = true;
|
||||||
|
private boolean useIso8601 = false;
|
||||||
|
|
||||||
private static class Context implements QueryTripsContext
|
private static class Context implements QueryTripsContext
|
||||||
{
|
{
|
||||||
|
@ -185,6 +186,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
this.canDoEquivs = canDoEquivs;
|
this.canDoEquivs = canDoEquivs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setUseIso8601(final boolean useIso8601)
|
||||||
|
{
|
||||||
|
this.useIso8601 = useIso8601;
|
||||||
|
}
|
||||||
|
|
||||||
protected TimeZone timeZone()
|
protected TimeZone timeZone()
|
||||||
{
|
{
|
||||||
return TimeZone.getTimeZone("CET");
|
return TimeZone.getTimeZone("CET");
|
||||||
|
@ -899,11 +905,12 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
final Calendar c = new GregorianCalendar(timeZone());
|
final Calendar c = new GregorianCalendar(timeZone());
|
||||||
c.setTime(date);
|
c.setTime(date);
|
||||||
uri.append("&REQ0JourneyDate=");
|
final String dateStr = useIso8601 ? String.format(Locale.ENGLISH, "%04d-%02d-%02d", c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1,
|
||||||
uri.append(String.format(Locale.ENGLISH, "%02d.%02d.%02d", c.get(Calendar.DAY_OF_MONTH), c.get(Calendar.MONTH) + 1,
|
c.get(Calendar.DAY_OF_MONTH)) : String.format(Locale.ENGLISH, "%02d.%02d.%02d", c.get(Calendar.DAY_OF_MONTH),
|
||||||
c.get(Calendar.YEAR) - 2000));
|
c.get(Calendar.MONTH) + 1, c.get(Calendar.YEAR) - 2000);
|
||||||
uri.append("&REQ0JourneyTime=");
|
uri.append("&REQ0JourneyDate=").append(ParserUtils.urlEncode(dateStr));
|
||||||
uri.append(String.format(Locale.ENGLISH, "%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)));
|
final String timeStr = String.format(Locale.ENGLISH, "%02d:%02d", c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE));
|
||||||
|
uri.append("&REQ0JourneyTime=").append(ParserUtils.urlEncode(timeStr));
|
||||||
|
|
||||||
final StringBuilder productsStr = new StringBuilder(numProductBits);
|
final StringBuilder productsStr = new StringBuilder(numProductBits);
|
||||||
if (products != null)
|
if (products != null)
|
||||||
|
|
|
@ -19,7 +19,9 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -29,6 +31,8 @@ import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
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.QueryTripsResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -47,6 +51,7 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
setClientType("ANDROID");
|
setClientType("ANDROID");
|
||||||
setCanDoEquivs(false);
|
setCanDoEquivs(false);
|
||||||
|
setUseIso8601(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -193,6 +198,26 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
return jsonGetStops(uri.toString());
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||||
|
{
|
||||||
|
uri.append("&h2g-direct=11");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryTripsResult queryTrips(final Location from, final Location via, final Location to, final Date date, final boolean dep,
|
||||||
|
final int numTrips, final Collection<Product> products, final WalkSpeed walkSpeed, final Accessibility accessibility,
|
||||||
|
final Set<Option> options) throws IOException
|
||||||
|
{
|
||||||
|
return queryTripsBinary(from, via, to, date, dep, numTrips, products, walkSpeed, accessibility, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later, final int numTrips) throws IOException
|
||||||
|
{
|
||||||
|
return queryMoreTripsBinary(contextObj, later, numTrips);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Product> defaultProducts()
|
public Collection<Product> defaultProducts()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue